int buzzerpin = 7;
void setup() {
Serial.begin(9600);
Serial.println("Type a, b, c, d, e");
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
pinMode (buzzerpin, OUTPUT);
}
}
void loop() {
// read the sensor
if (Serial.available() > 0) {
int inByte = Serial.read();
switch(inByte) {
case 'a':
digitalWrite(2, HIGH);
tone(buzzerpin, 50, 1000);
delay (1000);
break;
case 'b':
digitalWrite(3, HIGH);
tone(buzzerpin, 100, 1000);
delay (1000);
break;
case 'c':
digitalWrite(4, HIGH);
tone(buzzerpin, 150, 1000);
delay (1000);
break;
case 'd':
digitalWrite(5, HIGH);
tone(buzzerpin, 200, 1000);
delay (1000);
break;
case 'e':
digitalWrite(6, HIGH);
tone(buzzerpin, 250, 1000);
delay (1000);
break;
default:
// turn all the LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
}
}
}
}