Jukebox con suonerie
FunduinoUltimo aggiornamento il
Klingeltöne im RTTTL-Format per Tastenpad auswählen und abspielen
Ti serve
Altoparlante passivo - con presa XH2.54 3P
3,40 € *Codice articolo. F23108955Al prodotto — Altoparlante passivo - con presa XH2.54 3P
Modulo tastiera analogica con cinque tasti
3,00 € *Codice articolo. F23106483Al prodotto — Modulo tastiera analogica con cinque tasti
Modulo LCD 20x4 - I2C, illuminazione blu, 3,3-5 V
6,21 € *Codice articolo. F23107181Al prodotto — Modulo LCD 20x4 - I2C, illuminazione blu, 3,3-5 V
Tutti i 3 pezzi insieme 12,61 € *Pronto per la spedizione · Tempi di consegna: 1-3 giorni lavorativi
* Tutti i prezzi includono l’IVA prevista dalla legge, escluse le spese di spedizione.
Suonerie RTTTL
Componenti necessari
1 / 2
Lo schema elettrico
Installa le librerie necessarie
1 / 2
Includere le librerie e definire le variabili
Includere le librerie e definire le variabili
#include "PlayRtttl.hpp" #include "LiquidCrystal_I2C.h" // Imposta il nome dell'LCD (lcd) LiquidCrystal_I2C lcd(0x27, 20, 4); // Pin dell'altoparlante #define Lautsprecher 7 // Variabile per il tasto premuto sul tastierino int GedrueckteTaste; String TitelSong; char TeDeum[] = "Charpentier/Te_Deum:d=4,o=5,b=63:8c,8f,16f,16g,8a,8f,c6,8a,8a,8a#,16c6,16a#,16a,16a#,8c6,16g,16f,16g,16a,8g,8c,8f,16f,16g,8a,8f,c6,8a,8a,16a#,16c6,16a,16a#,g,16f,2f"; char FuerElise[] = "Beethoven/Für_Elise:d=8,o=5,b=125:32p,e6,d#6,e6,d#6,e6,b,d6,c6,4a.,32p,c,e,a,4b.,32p,e,g#,b,4c.6,32p,e,e6,d#6,e6,d#6,e6,b,d6,c6,4a.,32p,c,e,a,4b.,32p,d,c6,b,2a"; char OdeandieFreude[] = "Beethoven/Ode_an_die_Freude:d=4,o=6,b=100:a5,a5,a_5,c,c,a_5,a5,g5,f5,f5,g5,a5,a.5,8g5,2g5,"; char Bolero[] = "Ravel/Bolero:d=4,o=5,b=80:c6,8c6,16b,16c6,16d6,16c6,16b,16a,8c6,16c6,16a,c6,8c6,16b,16c6,16a,16g,16e,16f,2g,16g,16f,16e,16d,16e,16f,16g,16a,g,g,";
La parte di configurazione
La parte di configurazione
void setup()
{
// Avviare l’LCD
lcd.init();
// Accendere la retroilluminazione dell’LCD
lcd.backlight();
}Leggere il tastierino
Esempio: lettura del pulsante sinistro
// analogen Wert an A0 abfragen
int Analogwert = analogRead(A0);
switch (Analogwert)
{
case 0 ... 20:
// char-Array des Titels in String umwandeln
TitelSong = String(TeDeum);
// Funktion aufrufen, Interpret/Titel extrahieren
ZeigeTitel(TitelSong);
// Titel spielen
playRtttlBlocking(Lautsprecher, TeDeum);
break;
}La sezione loop completa
void loop()
{
// Tastenfeld am Eingang A0 abfragen
int Analogwert = analogRead(A0);
switch (Analogwert)
{
// linke Taste;
case 0 ... 20:
// char-Array des Titels in String umwandeln
TitelSong = String(TeDeum);
// Funktion aufrufen, Interpret/Titel extrahieren
ZeigeTitel();
// Titel abspielen
playRtttlBlocking(Lautsprecher, TeDeum);
break;
// obere Taste
case 30 ... 60:
TitelSong = String(FuerElise);
ZeigeTitel();
playRtttlBlocking(Lautsprecher, FuerElise);
break;
// rechte Taste
case 70 ... 120:
TitelSong = String(OdeandieFreude);
ZeigeTitel();
playRtttlBlocking(Lautsprecher, OdeandieFreude);
break;
// untere Taste
case 150 ... 200:
TitelSong = String(Bolero);
ZeigeTitel();
playRtttlBlocking(Lautsprecher, Bolero);
break;
// rechte äußere Taste -> Menü anzeigen
case 300 ... 400:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("1: Te Deum");
lcd.setCursor(0, 1);
lcd.print("2: F\365r Elise");
lcd.setCursor(0, 2);
lcd.print("3: Ode an die Freude");
lcd.setCursor(0, 3);
lcd.print("4: Bolero");
break;
}
}La funzione MostraTitolo
La funzione MostraTitolo
void ZeigeTitel()
{
// Teil des Strings bis zum ersten Doppelpunkt kürzen, enthält die Informationen zu Interpret und Titel
TitelSong = TitelSong.substring(0, TitelSong.indexOf(":"));
// _ durch leerzeichen ersetzen
TitelSong.replace("_", " ");
// erster Teil des Strings bis zum / -> Name des Interpreten
String Interpret = TitelSong.substring(0, TitelSong.indexOf("/"));
// zweiter Teil des Strings vom / + 1 bis zum Ende des Strings -> Name des Titels
String Titel = TitelSong.substring(TitelSong.indexOf("/") + 1, TitelSong.length());
// Titel auf dem LCD anzeigen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Spiele:");
lcd.setCursor(0, 1);
lcd.print(Interpret);
lcd.setCursor(0, 2);
lcd.print(Titel);
}Valuta le istruzioni