int leftPin = 3; // LED connected to digital pin 13
int rightPin = 11; // LED connected to digital pin 13
void playNote(int tone) {
for (int i=0; i < 100; i++) {
digitalWrite(leftPin, HIGH); // sets the LED on
digitalWrite(rightPin, HIGH); // sets the LED on
delayMicroseconds(tone); // waits for a second
digitalWrite(leftPin, LOW); // sets the LED off
delayMicroseconds(tone); // waits for a second
digitalWrite(leftPin, HIGH); // sets the LED on
digitalWrite(rightPin, LOW); // sets the LED on
delayMicroseconds(tone); // waits for a second
digitalWrite(leftPin, LOW); // sets the LED off
delayMicroseconds(tone); // waits for a second
}
}
void setup() // run once, when the sketch starts
{
pinMode(leftPin, OUTPUT); // sets the digital pin as output
pinMode(rightPin, OUTPUT); // sets the digital pin as output
}
void loop() //run over and over again
{
playNote(analogRead(5));
delay(200);
}