Hi, I'm making a "piano" with a buzzer and 8 buttons, I have almost the code to make it sound with the buttons, but now I'm trying to make a code using a BLE to send a letter or a command through an app and make a sound, and with a combination of sounds make a little melody, this is what I have until now but it dosen't make a sound, can you please help me showing me what the error or tell me some tips? Thank you very much.
#include <SoftwareSerial.h>
int NOTE_C3 = 128;
int B2;
int NOTE_D3 = 146;
int B3;
int NOTE_E3 = 164;
int B4;
int NOTE_F3 = 171;
int B5;
int NOTE_G3 = 196;
int B6;
int NOTE_A3 = 216;
int B7;
int NOTE_B3 = 242;
int B8;
int NOTE_C4 = 256;
int B9;
int duration = 200;
int pinBuzzer = 11;
void setup (){
pinMode (2,INPUT_PULLUP);
pinMode (3,INPUT_PULLUP);
pinMode (4,INPUT_PULLUP);
pinMode (5,INPUT_PULLUP);
pinMode (6,INPUT_PULLUP);
pinMode (7,INPUT_PULLUP);
pinMode (8,INPUT_PULLUP);
pinMode (9,INPUT_PULLUP);
}
void loop (){
B2=digitalRead(2);
B3=digitalRead(3);
B4=digitalRead(4);
B5=digitalRead(5);
B6=digitalRead(6);
B7=digitalRead(7);
B8=digitalRead(8);
B9=digitalRead(9);
if(Serial.available()){
char data = Serial.read ();
if (data == 'R'){
tone(pinBuzzer, NOTE_B3, duration);
delay(500);
}
}
}