Модуль mp3

WTV020 WTV020-SD WTV020SD-20SS
700,00 руб
mp3 2
wtv020-sd-to-arduino
Описание

Служит для воспроизведения mp3, wav файлов с SD карты.

Пример Кода:

//SELECTOR BTN = pin 6
//TRIGGER = pin 7
//RESET = PIN 2
//CLOCK = PIN 3
//DATA = PIN 4
//BUSY = PIN 5
#include 
int resetPin = 2; // The pin number of the reset pin.
int clockPin = 3; // The pin number of the clock pin.
int dataPin = 4; // The pin number of the data pin.
int busyPin = 5; // The pin number of the busy pin.
const int buttonPin = 6; // the pin that the SELECTOR pushbutton is attached to
const int triggerPin = 7; // the pin that the TRIGGER is attached to
// Variables will change:
int buttonPushCounter = 0; // counter for the number of SELECTOR button presses
int buttonState = 0;             // current state of the SELECTOR button
int lastButtonState = 0;         // previous state of the button
int triggerState = 0;            // current state of the Trigger
int lastTriggerState = 0;        // previous state of the Triger
long time = 0;           // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);
void setup() {
//Initializes the module.
wtv020sd16p.reset();
// initialize the SELECTOR and Trigger button pins as a inputs:
pinMode(buttonPin, INPUT);
pinMode(triggerPin, INPUT);
Serial.begin(9600); //Start serial interface (for debugging)
        
wtv020sd16p.asyncPlayVoice(0);
}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
triggerState = digitalRead(triggerPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState && millis() - time > debounce) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// went from off to on:
time = millis();
Serial.println("Selector Button Pushed");
// plays words
wtv020sd16p.asyncPlayVoice(5);
if (buttonPushCounter < 3)
{
buttonPushCounter++;
Serial.print("Selector Button State: ");
Serial.println(buttonPushCounter);
}
else buttonPushCounter = 1;
}
else {
}
}
// compare the triggerState to its previous state
if (triggerState != lastTriggerState) {
// if the state has changed, do something
if (triggerState == HIGH) {
         Serial.println("Trigger Pushed");
         Serial.print("Selector Button State: ");
         Serial.println(buttonPushCounter);
         SelectorPosition();
}
else {
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
lastTriggerState = triggerState;
}
void SelectorPosition(){
switch (buttonPushCounter) {
case 1:
         Serial.println("song1");
         wtv020sd16p.asyncPlayVoice(0);
         wtv020sd16p.stopVoice();
            
         break;
        
case 2: