Acoustic Controller
People always lazy to get off the bed to do something. They always ask help or tell others to help them to do the job, for example turn off the light. Also when we need to flush the toilet, we do not want to make our hand dirty, now the Acoustic Controller can help people to solve theses problem.
Supplies
1. Acoustic Chip
2. Rotational Motor
3. MEGA Arduino Board
4. Breadboard
5. LED Light
6. Resister
7. Wires
Connecting the Circuit
Connect the circuit as shown in the figures.
Programing Code
#include
Servo myservo; int pos = 0;
void setup() { Serial.begin(9600); pinMode(8,OUTPUT);
myservo.attach(9);
myservo.write(180); }
void loop() { int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if(sensorValue > 50){ //當音量超過一定數值,這個數值依個別情況修改 digitalWrite(8,HIGH); //燈亮
for (pos = 0;
pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
for (pos = 180; pos >= 0; pos -= 1) {
// goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
}else{
digitalWrite(8,LOW); //燈滅
myservo.write(90); }
delay(100);
}