4
Plays a pitch that changes based on a changing analog input
7
* 3 force-sensing resistors from +5V to analog in 0 through 5
8
* 3 10K resistors from analog in 0 through 5 to ground
9
* 8-ohm speaker on digital pin 8
15
This example code is in the public domain.
17
http://arduino.cc/en/Tutorial/Tone3
23
const int threshold = 10; // minimum reading of the sensors that generates a note
25
// notes to play, corresponding to the 3 sensors:
27
NOTE_A4, NOTE_B4,NOTE_C3 };
34
for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
35
// get a sensor reading:
36
int sensorReading = analogRead(thisSensor);
38
// if the sensor is pressed hard enough:
39
if (sensorReading > threshold) {
40
// play the note corresponding to this sensor:
41
tone(8, notes[thisSensor], 20);