This Arduino project uses an ultrasonic sensor to detect when a door is opened or closed, and moves a servo motor to turn a light switch on or off.
- Arduino Uno R3
- Ultrasonic sensor (HC-SR04)
- Servo motor
- Jumper wires
- Breadboard
- Ultrasonic Sensor:
- VCC to Arduino 5V
- GND to Arduino GND
- Trig to Arduino pin 9
- Echo to Arduino pin 8
- Servo Motor:
- VCC to Arduino 5V
- GND to Arduino GND
- Signal to Arduino pin 6
- Connect the components as per the circuit diagram.
- Upload the code to your Arduino board.
- Mount the wall with ultrasonic sensor facing door.
- Observe the servo motor movement as the door opens and closes.
- I made a simple 3d design for a case, I'm going to get it printed later this week and I'll add pics of it working. For now the STL is in one of the files so feel free to check it out or edit it :)