Πίνακας περιεχομένων:

Rocola Luis Hernández E Ignacio Casado: 7 Βήματα
Rocola Luis Hernández E Ignacio Casado: 7 Βήματα

Βίντεο: Rocola Luis Hernández E Ignacio Casado: 7 Βήματα

Βίντεο: Rocola Luis Hernández E Ignacio Casado: 7 Βήματα
Βίντεο: La Llorona - Daniel Robledo 2024, Σεπτέμβριος
Anonim
Rocola Luis Hernández E Ignacio Casado
Rocola Luis Hernández E Ignacio Casado

Esta es una rocola que cuenta con dos canciones, el tema de Harry Potter y la canción de Despacito de Luis Fonsi

Βήμα 1: Υλικά

1 Protoboard

1 Arduino UNO

καλώδια άλτης macho-hembra y macho-macho

1 pantalla LCD 16x2

2 Buzzer pasivo

2 Πλήκτρο

1 καλώδιο USB για Arduino

1 fuente de poder externa

Βήμα 2: Προγραμματισμός

Προγραμματισμός
Προγραμματισμός
Προγραμματισμός
Προγραμματισμός

Primero, hay que incluir la biblioteca del LCD en el programa y configurarlo con los pines a los que esta conectado. Luego, hay que instanciar las variables que determinaran la cancion, los pines de los 2 botones, una variable "anti-derrames" y el pin para el buzzer.

#περιλαμβάνω

// librería para manejar pantallas LCD

LiquidCrystal LCD (12, 11, 5, 4, 3, 2); // Indica que pines se estan utilizando

int cantidad = 0;

const int botonI = 10; const int botonD = 9; int αντιδιαγράμματα = 0; // εκτίμηση μεταβλητής για μια υπηρεσία για την παρακολούθηση της οθόνης LCD 3 cosas al mismo tiempo int buzzer_pin = 6;

Después de eso, hay que nombrar a las funciones que van a:

  1. Definir el tono a tocar (según el pin del buzzer, la nota y la duración de la misma).
  2. Definir las notas (en letras), dándoles un valor único de Hz.
  3. Definir la estructura de las notas (nota, semi-nota, κλπ).

Y por ultimo, definir el tempo en milisegundos

void setTone (int pin, int note, int duration) {tone (pin, note, duration); καθυστέρηση (διάρκεια)? noTone (καρφίτσα); } struct MusicStruct {int A = 550; int As = 582; int Β = 617; int C = 654; int Cs = 693; int D = 734; int Ds = 777; int Ε = 824; int F = 873; int Fs = 925; int G = 980; int Gs = 1003; int A2 = 1100; int A2s = 1165; int Β2 = 1234; int C3 = 1308; int C3s = 1385; int D3 = 1555; }ΜΟΥΣΙΚΗ; struct LengthStruct {float half = 0,5; float one = 1,0; float one_half = 1,5; float two = 2.0; float two_half = 2,5; }Μήκος;

int tempo = 400; // velocidad de la composicion

Después de definir todo eso, podemos empezar la parte interesante del programa.

Primero, hay que:

  • Σειρά παρακολούθησης
  • Definir los modos de los pines de los botones y el buzzer
  • Encender el LCD και poner el cursor en la posición inicial

void setup () {Serial.begin (9600); pinMode (botonI, INPUT_PULLUP); pinMode (botonD, INPUT_PULLUP);

// Sección de pantalla LCD

lcd. αρχή (16, 2); // Enciende lcd lcd.clear (); lcd.setCursor (0, 0); // El proximo mensaje apracecera en la cordenada 0, 0 pinMode (buzzer_pin, OUTPUT);

}

Luego, necesitamos instanciar las funciones de las funciones, que van a dar el orden, tono, tiempo de las 2 canciones que vamos a tener en este proyecto (despacito y el tema principal de Harry Potter).

Usaremos 2 formas de tocar canciones en este proyecto:

  1. Usando la función setTone, que definimos antes (Χάρι Πότερ)
  2. Usando la función tone del buzzer del Arduino (Despacito)

Nota del autor: La función para despacito solo toca los primeros 12 segundos de la canción, originalment el el código era de 856 lineas

void jarri () {setTone (buzzer_pin, Music. B, tempo * Length.one); setTone (buzzer_pin, Music. E, tempo * Length.one_half); setTone (buzzer_pin, Music. G, tempo * Length.half); setTone (buzzer_pin, Music. F, tempo * Length.one); setTone (buzzer_pin, Music. E, tempo * Length.two); setTone (buzzer_pin, Music. B2, tempo * Length.one); setTone (buzzer_pin, Music. A2, tempo * Length.two_half); setTone (buzzer_pin, Music. Fs, tempo * Length.two_half); setTone (buzzer_pin, Music. E, tempo * Length.one_half); setTone (buzzer_pin, Music. G, tempo * Length.half); setTone (buzzer_pin, Music. F, tempo * Length.one); setTone (buzzer_pin, Music. Ds, tempo * Length.two); setTone (buzzer_pin, Music. F, tempo * Length.one); setTone (buzzer_pin, Music. B, tempo * Length.two_half);} void Despacito () {tone (buzzer_pin, 587, 709.720327982); καθυστέρηση (788.578142202); καθυστέρηση (10.3082110092); τόνος (buzzer_pin, 554, 709.720327982); καθυστέρηση (788.578142202); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367) καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 134.52215367) καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 412.843850917); καθυστέρηση (458.715389908); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 391, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 554, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 587, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 412.843850917); καθυστέρηση (458.715389908); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 134.52215367) καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 41.7482545872); καθυστέρηση (46.3869495413); καθυστέρηση (36.0787385321); τόνος (buzzer_pin, 440, 37.109559633); καθυστέρηση (41.2328440367); καθυστέρηση (30.9246330275); τόνος (buzzer_pin, 440, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 587, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 587, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 587, 46.3869495413); καθυστέρηση (51.5410550459); καθυστέρηση (30.9246330275); τόνος (buzzer_pin, 587, 46.3869495413); καθυστέρηση (51.5410550459); καθυστέρηση (20.6164220183) τόνος (buzzer_pin, 587, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 659, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 659, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 554, 691.165548165) καθυστέρηση (767.961720183) καθυστέρηση (314.40043578); τόνος (buzzer_pin, 587, 552.004699541) καθυστέρηση (613.338555046); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 554, 552.004699541) καθυστέρηση (613.338555046); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367) καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 369, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 46.3869495413); καθυστέρηση (51.5410550459); καθυστέρηση (30.9246330275); τόνος (buzzer_pin, 493, 46.3869495413); καθυστέρηση (51.5410550459); καθυστέρηση (20.6164220183) τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 134.52215367); καθυστέρηση (149.469059633) καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 440, 134.52215367) καθυστέρηση (149.469059633); καθυστέρηση (5.15410550459); τόνος (buzzer_pin, 493, 273.683002294); καθυστέρηση (304.092224771); καθυστέρηση (5.15410550459); }

Una vez tengamos todo esto, podemos pasar a la parte mas importante del programa del Arduino… el Loop ()

Primero, definimos un label llamado leibel (espectacular nombre, lo sé), para que lleve al inicio del loop () cuando termine cada canción. Πρώτα απ 'όλα, είναι πολύ ευαίσθητο για τις μεταβλητές αντι-δράσεις που έχουν προηγηθεί, για παράδειγμα, για περισσότερες από μία LCD αφίσες και ακατανόητες θάλασσες.

Luego, hay que poner que cada vez que se oprima un botón se cambie el valor que define la canción que se toca.

void loop () {leibel: if ((antiderrames == 0) && (digitalRead (botonI) == 1) && (digitalRead (botonD) == 1)) {lcd.setCursor (0, 0); lcd.print ("Elegir cancion"); // CAMBIA el icono lcd.setCursor (0, 1); lcd.print ("1 o 2"); } else {if (digitalRead (botonI) == 0) {καθυστέρηση (400); lcd.clear (); αν (cantidad == 0) {cantidad = 1; } αντιδιαγράμματα ++; } if (digitalRead (botonD) == 0) {καθυστέρηση (400); lcd.clear (); εάν (cantidad == 1) {cantidad = 0; } αντιδιαγράμματα ++; } if (cantidad == 0) {lcd.setCursor (0, 0); lcd.print ("Χάρι Πότερ"); // CAMBIA el icono lcd.setCursor (0, 1); lcd.print ("Θέμα"); jarri (); αντιδιαγράμματα = 0; lcd.clear (); Goto leibel? // volvemos al inicio

}

else if (cantidad == 1); {

lcd.setCursor (0, 0); lcd.print ("Despacito"); // CAMBIA el icono lcd.setCursor (0, 1); lcd.print ("Luis Fonsi"); Despacito (); αντιδιαγράμματα = 0; lcd.clear (); Goto leibel? // volvemos al inicio}}}

Junto con la programación, también se probó la funcionalidad de la pantalla LCD 16x2, για να προστατεύσετε το πρόγραμμα και να το μάθετε για τον τελικό του προγράμματος.

Βήμα 3: 4. Escoger Canciones Para Programarla

4. Escoger Canciones Para Programarla
4. Escoger Canciones Para Programarla
4. Escoger Canciones Para Programarla
4. Escoger Canciones Para Programarla

Se buscaron 2 canciones para programarlas y así incluirlas para la rocola. En este caso serían las canciones de "Despacito" de Luis Fonsi y el tema de la película Χάρι Πότερ.

Βήμα 4: Unir Programas

Unir Programas
Unir Programas

Después de tener la programación de los botones, la pantalla y las canciones? se unieron para así probar si eran συμβατά y si no, modificarlos en tinkercad.

Βήμα 5: Convertirlo En Físico

Convertirlo En Físico
Convertirlo En Físico
Convertirlo En Físico
Convertirlo En Físico

Después de comprobar que sí funcionara en la página de tinkercad, επιλέξτε αντίγραφο υλικού για ver los resultados. Απαγορεύεται το εμπόριο, το οποίο δεν μπορεί να σας ενοχλήσει, δεν μπορείτε να χρησιμοποιήσετε το παντάλλωμα που μπορεί να χρησιμοποιηθεί για να πωληθεί. Es por esto que en la presentación final solo incluye los botones y el buzzer.

Βήμα 6: Máquinas Utilizadas

Máquinas Utilizadas
Máquinas Utilizadas

Χρησιμοποιήστε το cortadora láser del Maker-Space para crear la carcasa donde irían todos los circuitos.

Αυτοκόλλητο για το cortadora de vinilo para hacer y decorar la carcasa

Se utilizo el taladro de pedestal del Maker-space para hacer los agujeros para el buzzer y el cable del Arduino

Βήμα 7: Συνιστώμενα

Συνιστώμενες
Συνιστώμενες

Algunas recomendaciones si se piensa replicar este proyecto para mejores resultados es:

- Probar previamente el programa en la página de Tinkercad para ver cómo funciona. Así como verificar los cableados y conexiones entre el protoboard y el arduino.

- Αλλάντ, επαληθεύοντας ότι θα επικοινωνήσω μαζί σας για να σας βοηθήσω, καθώς και για να το κάνετε αυτό, καθώς και για να συνθέσετε.

- Όλο το αντίγραφο του υλικού της σελίδας Tinkercad, conectar todo de forma cuidadosa para no romper una pieza y verificar que no se salgan de sus sitios.

- Medir las dimensiones para la caja, así se podrá evitar que quede demasiado grande o muy pequeña.

Συνιστάται: