Class 9: Build the complete circuit and Program
Since the mission this week is to build the core, we had searched many many things on the Internet and met different problems and did many changes! The content in this documentation might be a little bit more.
Tools
# | Name | Number | Note |
---|---|---|---|
1 | Shanghaiuno board | 1 | Arduino UNO is OK too |
2 | Potentialmeter | 5 | The number is determined by you |
3 | Slient Buzzer | 5 | The number is the same as potentialmeter |
4 | Button | 1 | ### |
5 | LED light | 2 | Different colours |
6 | Wires | Decided by you | ### |
7 | Breadboard | 1 | ### |
Step1:Figuring out the final piece
We have done a very simple circuit to realize playing some simple music such as Happy Song. Then, this is our core, we need to plus some more features on it. Actually, what I want to finally present is an effector, which can change the output frequency by control some types of input.
Step2:Trying to program
Step3:Restruct
digitalWrite(7,HIGH);
digitalWrite(4,LOW);
while (digitalRead(2) == 0) {
int add_val1 = -200 + (int)(analogRead(A0) / 2.5);
int add_val2 = -200 + (int)(analogRead(A1) / 2.5);
int add_val3 = -200 +(int)(analogRead(A2) / 2.5);
int now_delay = (int)analogRead(A3) / 5;
tone(outpin,800+add_val1);
delay(now_delay);
noTone(outpin);
tone(outpin2, 1000+add_val2);
delay(now_delay);
noTone(outpin2);
tone(outpin3,1200+add_val3);
delay(now_delay);
noTone(outpin3);
}
noTone(outpin);
noTone(outpin2);
noTone(outpin3);
state = 1;
}
delay(500);
}