const int pinBuzzer=8;
const int Do=261; const int Re=294; const int Mi=329; const int Fa= 349; const int Sol=392; const int La=440; const int p=0; const int SolB=196; char c;
void setup() { pinMode(pinBuzzer, OUTPUT); Serial.begin(9600); }
void loop() { c=Serial.read(); switch(c){
case ‘q’: tone(pinBuzzer, Do, 50); Serial.println(“Do”); break;
case ‘w’: tone(pinBuzzer, Re, 50); Serial.println(“Re”); break;
|
case ‘e’:
tone(pinBuzzer, Mi, 50); Serial.println(“Mi”); break;
case ‘r’: tone(pinBuzzer, Fa, 50); Serial.println(“Fa”); break;
case ‘t’: tone(pinBuzzer, Sol, 50); Serial.println(“Sol”); break;
case ‘y’: tone(pinBuzzer, La, 50); Serial.println(“La”); break;
case ‘u’: tone(pinBuzzer, SolB, 50); Serial.println(“SolB”); break; } } |