#define PR A0
#define BUZZER 10
#define LED 3
int notes[] = {
262, 277, 294, 311,
330, 349, 370, 392,
415, 440, 466, 494
};
void setup() {
pinMode(PR, INPUT);
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
}
void loop() {
int prValue = analogRead(PR);
int note = map(prValue, 0, 1016, 0, 11);
tone(BUZZER, notes[note]);
if (note >= 9) {
digitalWrite(LED, HIGH);
} else {
digitalWrite(LED, LOW);
}
delay(30);
}