Introduction: Electronic Organ
Hello, Everyone. This is a series of courses, I will share how to use cartons and arduino to make something interesting,today,I'll share with you a Electronic Organ.The project is relatively simple, so according to the steps produced is not too difficult.
Step 1: You Need to Prepare These Materials
Step 2: Circuit Diagram
Step 3: Assembly
Step 4: Code
void setup()
{
pinMode(1, INPUT);
pinMode(13, OUTPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
}
void loop()
{
analogWrite(10,1);
if (digitalRead(1)) {
tone(13,262);
} else if (digitalRead(2)) {
tone(13,294);
} else if (digitalRead(3)) {
tone(13,330);
} else if (digitalRead(4)) {
tone(13,349);
} else if (digitalRead(5)) {
tone(13,392);
} else if (digitalRead(6)) {
tone(13,440);
} else if (digitalRead(7)) {
tone(13,494);
} else {
noTone(13);
}
}
Step 5: GameRules
Press a button and the electronic organ makes a sound.
These seven buttons correspond to DO,RE,MI,FA,SUO,LA,XI