PC switch
You are too lazy to turn on your computer by pressing a button? Need
a more practical solution?
I'll show you the BEST way to do it!
What you will need:
- arduino
- 6 wires
- a servo motor
- a sound sensor
- some tape to stabilize the servo motor
Circuit:
We connect the servo motor to 3.3V, GND and D3; and we connect the sound sensor to 5V, GND and D2.
Code:
#include <Servo.h> // We need to include this library to use the servo motor.
int soundPin = 2; // Sound sensor to D2.
int servoPin = 3; // Servo motor to D3.
int soundDetection;
Servo Myservo; // We name the servo.
void setup() {
pinMode(soundPin, INPUT);
Myservo.attach(servoPin);
}
void loop() {
soundDetection = digitalRead(soundPin); // We save the value of the sound sensor in this variable. It can be only 0 or 1.
if (soundDetection == 1){ // If the sensor detects sound the servo moves.
Myservo.write(45);
delay(500);
Myservo.write(0);
delay(500);
}
}
If something doesn't work, try to adjust the potentiometer of the sound sensor.
Result:
Just clap 👏 and your computer will turn on (or off)!
I had to put some weight on the servo because the tape didn't hold it properly. 🙄
