Devices & Components
Arduino Starter Kit [English]
USB 2.0 Cable Type A/B
Arduino Uno Rev3
Resistor 10k ohm
Breadboard Jumper Wire Pack (200mm&100mm)
Push Button
Resistor 1 M ohm
Mini breadboard - White
Resistor 330 ohm
Piezo Buzzer
Hardware & Tools
Laptop
Software & Tools
Fritzing
Arduino IDE
Project description
Code
Code for Digital Keyboard with Sound Output
cpp
Use this code in Arduino IDE.
1int notes[] = {262, 294, 330, 349}; 2 3void setup() { 4 Serial.begin(9600); 5} 6 7void loop() { 8 int keyVal = analogRead(A0); 9 Serial.println(keyVal); 10 11 if (keyVal == 1023) { 12 tone(8, notes[0]); 13 } else if (keyVal >= 990 && keyVal <= 1010) { 14 tone(8, notes[1]); 15 } else if (keyVal >= 505 && keyVal <= 515) { 16 tone(8, notes[2]); 17 } else if (keyVal >= 5 && keyVal <= 10) { 18 tone(8, notes[3]); 19 } else { 20 noTone(8); 21 } 22}
Downloadable files
Digital Keyboard with Sound Output using Arduino
Arduino Project - Rexhep Mustafovski .pdf
Documentation
Fritzing Circuit Diagram – Digital Keyboard with Arduino
Rexhep Mustafovski.png

Comments
Only logged in users can leave comments