Доброе время суток.
Ребята помогите сделать звук при нажатии на кнопки,что б на каждой кнопке играла своя музыка. Модуль mp3 купил (DFPlayer), но вот как подключить и как написать скетч не шарю.
Схему подключения и скетч брал из интернета, все собрал, скетч загрузил и все работает, но детям еще звук захотелось. Прошерстил весь интернет схему подключения нашел, но как привязать на кнопки не нашел
Вот изначальная схема кнопок, как сюда подключить mp3 модуль и привязать на кнопки, помогите кто понимает.
Вот сам скетч
bool _gtv1;
bool _gtv2;
bool _gtv3;
bool _gtv4;
bool _bounseInputD11S = 0;
bool _bounseInputD11O = 0;
unsigned long _bounseInputD11P = 0UL;
bool _bounseInputD12S = 0;
bool _bounseInputD12O = 0;
unsigned long _bounseInputD12P = 0UL;
bool _tim1I = 0;
bool _tim1O = 0;
unsigned long _tim1P = 0UL;
bool _tim2I = 0;
bool _tim2O = 0;
unsigned long _tim2P = 0UL;
bool _trgs1 = 0;
bool _trgs2 = 0;
void setup()
{
pinMode(12, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(10, OUTPUT);
digitalWrite(10, 0);
pinMode(9, OUTPUT);
digitalWrite(9, 0);
_bounseInputD11O = digitalRead(11);
_bounseInputD12O = digitalRead(12);
}
void loop()
{
bool _bounceInputTmpD11 = (digitalRead (11));
if (_bounseInputD11S)
{
if (millis() >= (_bounseInputD11P + 40))
{
_bounseInputD11O= _bounceInputTmpD11;
_bounseInputD11S=0;
}
}
else
{
if (_bounceInputTmpD11 != _bounseInputD11O)
{
_bounseInputD11S=1;
_bounseInputD11P = millis();
}
}
bool _bounceInputTmpD12 = (digitalRead (12));
if (_bounseInputD12S)
{
if (millis() >= (_bounseInputD12P + 40))
{
_bounseInputD12O= _bounceInputTmpD12;
_bounseInputD12S=0;
}
}
else
{
if (_bounceInputTmpD12 != _bounseInputD12O)
{
_bounseInputD12S=1;
_bounseInputD12P = millis();
}
}
//Плата:1
if (_gtv3)
{
if (_tim1I)
{
if (_isTimer(_tim1P, 5000))
{
_tim1O = 1;
}
}
else
{
_tim1I =1;
_tim1P = millis();
}
}
else
{
_tim1O = 0;
_tim1I = 0;
}
if(!(_gtv1)) _trgs1 = 1;
if(((_gtv4) || (_tim1O))) _trgs1 = 0;
_gtv3 = _trgs1;
digitalWrite(9, !(_gtv3));
_gtv1 = _bounseInputD11O;
digitalWrite(10, !(_gtv4));
_gtv2 = _bounseInputD12O;
if (_gtv4)
{
if (_tim2I)
{
if (_isTimer(_tim2P, 5000))
{
_tim2O = 1;
}
}
else
{
_tim2I =1;
_tim2P = millis();
}
}
else
{
_tim2O = 0;
_tim2I = 0;
}
if(!(_gtv2)) _trgs2 = 1;
if(((_gtv3) || (_tim2O))) _trgs2 = 0;
_gtv4 = _trgs2;
}
bool _isTimer(unsigned long startTime, unsigned long period)
{
unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime)
{
return (currentTime>=(startTime + period));
}
else
{
return (currentTime >=(4294967295-startTime+period));
}
}