ArduinoGeneral

Help with audio loop (DFPlayer mini)

userHead galves151097 2019-09-24 09:28:33 2582 Views3 Replies
Hello, I am setting up a project that is a plug-in keyboard, (a toy), where the child will put the letters and a led will light and play an audio speaking letters (A, B, C ...).

So I am using MEGA arduino, and the DFPlayer Mini board for this project, besides 26 green LEDs, everything is working fine.

The contacts fit leds and even the audio. But the audio goes into a loop, and I would like the audio of each letter to be played only once.
How can I be solving this?
I'm sure it's something about my code that is attached here.
So how do I disable looping using DFPlayer mini ????
Code: Select all
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
SoftwareSerial mySoftwareSerial(0, 1);
DFRobotDFPlayerMini myDFPlayer;
int equalizacao = 0;

const int nElements = 'Z' - 'A' + 1;
const byte ledPin[nElements] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 };
const byte buttonPin[nElements] = { 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53 };
bool value[nElements];
bool lastValue[nElements];

void setup()
{
  mySoftwareSerial.begin(9600);
  myDFPlayer.begin(mySoftwareSerial);
  myDFPlayer.setTimeOut(500);
  myDFPlayer.volume(30);
  myDFPlayer.EQ(0);

  for (int i = 0; i < nElements; i++ ) {
    pinMode(ledPin[i], OUTPUT);
    digitalWrite(ledPin[i], LOW);
    pinMode(buttonPin[i], INPUT);
  }
}


void loop()
{
  for (int i = 0; i < nElements; i++) {
    value[i] = digitalRead(buttonPin[i]);
    if ( value[i] != lastValue[i] ) {
      lastValue[i] = value[i];
      if (value[i] == HIGH)   {
        digitalWrite(ledPin[i], HIGH);
        myDFPlayer.play(i);
        delay(2000);
      }  else  {
        digitalWrite(ledPin[i], LOW);
      }
    }
  }
  if (value[25] == HIGH && value[0] == HIGH) {
    myDFPlayer.play(27);
  }
}
2019-09-24 19:05:03 Haha
Yes, I already checked, so I am here, I am not giving support, I need support.
I'm have one question: So how do I disable looping using DFPlayer mini ????
userHeadPic galves151097