I dont know why my device (servo, buzzer) do it twice althought i only press button in blynk app once . But only get 1 notification , 1 email.
This is my code :
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>
#include "music.h"
Servo myservo;
int speakerPin = 15;//Chân được nối với loa hoặc buzzer
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4
};
int noteDurations[] = {
4, 8, 8, 4,4,4,4,4
};
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "d61bad57c3cf48e49fc240c24456cd23";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "carrotne";
char pass[] = "12341234";
void setup()
{
pinMode(15, OUTPUT);//buzzer
for (int thisNote = 0; thisNote < 8; thisNote++) {
int noteDuration = 1000/noteDurations[thisNote];
tone(speakerPin, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(speakerPin);
}
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();}
BLYNK_WRITE( V1 )
{ for (int thisNote = 0; thisNote < 8; thisNote++) {
int noteDuration = 1000/noteDurations[thisNote];
tone(speakerPin, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(speakerPin);
}
myservo.attach(13);
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
myservo.detach();
Blynk.notify("Your pet has been fed");
Blynk.email("zzz@gmail.com","Done","Success")
}
Please tell me how to repair it. Sorry bad english !