Modulo MP3 DFPlayer Mini su Arduino
FunduinoPubblicato il
Von der SD-Karte bis zur Türklingel mit eigener Ansage
Ti serve
Buzzer 5 V - segnalatore elettromagnetico, 2400 Hz
0,90 € *Codice articolo. F23108736Al prodotto — Buzzer 5 V - segnalatore elettromagnetico, 2400 Hz
Lettore MP3 TF-16P V3.0 - microSD fino a 32 GB, seriale
3,11 € *Codice articolo. FUN-1010563Al prodotto — Lettore MP3 TF-16P V3.0 - microSD fino a 32 GB, seriale
Microcontrollore Funduino UNO R3 - ATmega328P, 16 MHz, per Arduino
11,12 € *Codice articolo. F23107480Al prodotto — Microcontrollore Funduino UNO R3 - ATmega328P, 16 MHz, per Arduino
Breadboard da 830 contatti - per Arduino, senza saldatura
2,90 € *Codice articolo. FUN-1010553Al prodotto — Breadboard da 830 contatti - per Arduino, senza saldatura
Cavi per breadboard maschio-maschio - 40 pezzi, 20 cm
1,74 € *Codice articolo. FUN-1010558Al prodotto — Cavi per breadboard maschio-maschio - 40 pezzi, 20 cm
Tutti i 5 pezzi insieme 19,77 € *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.
Preparare la scheda SD
Lo schema elettrico
Installare e testare la libreria
1 / 2
Il codice di programmazione in forma minima
Forma minima: riprodurre un file MP3
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void setup()
{
mySoftwareSerial.begin(9600);
myDFPlayer.volume(30); // Lautstärke auf Maximum (30)
}
void loop()
{
myDFPlayer.play(1); // Spielt die erste MP3-Datei ab
delay(3000); // Nach dem Abspielen pausiert der Sketch drei Sekunden.
}Campanello con annuncio vocale
Campanello con annuncio vocale
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
int taster = 7; // La parola "taster" ora indica il valore 7.
int tasterstatus = 0; // Qui viene memorizzato se il pulsante è premuto oppure no.
void setup()
{
mySoftwareSerial.begin(9600);
myDFPlayer.volume(30); // Volume al massimo (30)
pinMode(taster, INPUT); // Il pin con il pulsante (pin 7) è ora un ingresso.
}
void loop()
{
tasterstatus = digitalRead(taster); // Leggi il pin 7. Il risultato è HIGH (5 volt) oppure LOW (0 volt).
if (tasterstatus == HIGH) // Se il pulsante è premuto …
{
myDFPlayer.play(1); // … il modulo riproduce il primo file MP3.
}
}La pianta da appartamento sgridona
La pianta da appartamento sgridona
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
int messwert = 0; // Qui verrà salvato il valore misurato dal sensore.
void setup()
{
mySoftwareSerial.begin(9600);
myDFPlayer.volume(30); // Volume al massimo (30)
}
void loop()
{
messwert = analogRead(A0); // La tensione sul sensore viene letta e salvata in "messwert".
if (messwert <= 300) // Se il valore misurato è pari o inferiore a 300 …
{
myDFPlayer.play(1); // … il modulo riproduce il primo file MP3.
}
}Fatto!
Valuta le istruzioni