int leftPin = 3; // LED connected to digital pin 13
int rightPin = 11; // LED connected to digital pin 13
int value = 0;
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
{
value = analogRead(5);
if (value < 10) {
} else
if (value < 128) playNote(1911);
else
if (value < 256) playNote(1703);
else
if (value < 384) playNote(1517);
else
if (value < 512) playNote(1432);
else
if (value < 640) playNote(1276);
else
if (value < 768) playNote(1136);
else
if (value < 896) playNote(1012);
else playNote(956);
delay(200);
}