Download examples/02.Digital/toneKeyboard/toneKeyboard.ino from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 996 Bytes
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/examples/02.Digital/toneKeyboard/toneKeyboard.ino
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development/examples/02.Digital/toneKeyboard/toneKeyboard.ino
-
curl -L -o toneKeyboard.ino https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/examples/02.Digital/toneKeyboard/toneKeyboard.ino
996 Bytes
| /* | |
| Keyboard | |
| Plays a pitch that changes based on a changing analog input | |
| circuit: | |
| - three force-sensing resistors from +5V to analog in 0 through 5 | |
| - three 10 kilohm resistors from analog in 0 through 5 to ground | |
| - 8 ohm speaker on digital pin 8 | |
| created 21 Jan 2010 | |
| modified 9 Apr 2012 | |
| by Tom Igoe | |
| This example code is in the public domain. | |
| https://www.arduino.cc/en/Tutorial/BuiltInExamples/toneKeyboard | |
| */ | |
| const int threshold = 10; // minimum reading of the sensors that generates a note | |
| // notes to play, corresponding to the 3 sensors: | |
| int notes[] = { | |
| NOTE_A4, NOTE_B4, NOTE_C3 | |
| }; | |
| void setup() { | |
| } | |
| void loop() { | |
| for (int thisSensor = 0; thisSensor < 3; thisSensor++) { | |
| // get a sensor reading: | |
| int sensorReading = analogRead(thisSensor); | |
| // if the sensor is pressed hard enough: | |
| if (sensorReading > threshold) { | |
| // play the note corresponding to this sensor: | |
| tone(8, notes[thisSensor], 20); | |
| } | |
| } | |
| } | |