Simple Piano
.png)
piano thing
Supplies
buttons
buzzer
potentiometer
breadboard
arduino uno
wires
Add Arduino
.png)
add
Add Breadboard
.png)
Add Potentiometer
.png)
Add Buzzer
.png)
More Wires
.png)
More Wires
.png)
Bunch More Wires
.png)
add more wires
Add More Wires
.png)
add more wires
Add a Bunch More Wire
.png)
wires
Resistor
.png)
add resistors
Buttons
.png)
add buttons
Code
add code
int pos = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(8, OUTPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
}
void loop()
{
// if button press on A0 is detected
if (digitalRead(A0) == HIGH) {
tone(8, 92, 100);
}
// if button press on A1 is detected
if (digitalRead(A1) == HIGH) {
tone(8, 165, 100);
}
// if button press on A0 is detected
if (digitalRead(A2) == HIGH) {
tone(8, 294, 100);
}
if (digitalRead(A3) == HIGH) {
tone(8, 523, 100);
}
if (digitalRead(A4) == HIGH) {
tone(8, 932, 100);
}
if (digitalRead(A5) == HIGH) {
tone(8, 1661, 100);
}
delay(10);
}