2 Melody keyboard with Input Pullup Serial
3 Plays a pitch that changes based on 3 digital inputs
5 This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
6 digital input on pin 2 and prints the results to the serial monitor.
9 * 3 buttons in pin 2,3,4 with no resistors
10 * Piezo on digital pin 9
11 * Serial debug is available
13 This example code is in the public domain
17 // Please take care of the include path
18 #include "/root/arduino/sketchbook-lessons/piezo_mario_tune/pitches.h";
21 NOTE_A4, NOTE_C4,NOTE_E3 };
24 //start serial connection
26 //configure pin2 as an input and enable the internal pull-up resistor
27 pinMode(2, INPUT_PULLUP);
28 pinMode(3, INPUT_PULLUP);
29 pinMode(4, INPUT_PULLUP);
36 for (int thisSensor = 2; thisSensor < 5; thisSensor++) {
37 int sensorReading = digitalRead(thisSensor);
38 if (sensorReading == LOW) {
39 Serial.println(thisSensor);
40 tone(9, notes[thisSensor -2], 50); // Notes array is translated