int speakerPin = 0; char c; int ton =0; int tones[] = { 1136, 1014, 1915, 1700, 1519, 1432, 1275 }; int tempo = 300; void setup() { Serial.swap(1); Serial.begin(9600); pinMode(speakerPin, OUTPUT); } void loop() { while (Serial.available() > 0) { c= Serial.read(); ton = c-96; // Serial.println(ton); // Serial.println(c); playTone(tones[ton-1], tempo); } } void playTone(int tone, int duration) { for (long i = 0; i < duration * 1000L; i += tone * 2) { digitalWrite(speakerPin, HIGH); delayMicroseconds(tone); digitalWrite(speakerPin, LOW); delayMicroseconds(tone); } }