This project is inspired by the idea of automatic door that opens when somebody gets within the range.
Software used:
TinkerCad to design & simulate circuit.
Arduino IDE to upload the code to the Arduino
Components:
Arduino Uno
Ultrasonic sensor
LEDs
Servo motor
330 ohm resistance
Jumpers
Breadboard
ON-OFF switch
Input components: Ultrasonic sensor & switch
Action components: LED & Servo motor
First, the switch is used to turn on the whole circuit, when the switch is ON a yellow led lights.
If an objects appears within a range of 30cm the ultrasonic triggers a green LED shows that the door is open, and servo rotates 90 degrees to point at this LED.
If no object appears within the specified range a red LED shows that the door is closed, and servo rotates 90 degrees to point at this LED.
Common GND & Vcc is connected from Arduino to breadboard.
LEDs ground is connected to the common ground through 330 ohm resistance, and positive LEDs is connected to the Arduino pins (10,11,12)
Ultrasonic sensor's GND & Vcc are connected to common ones, and trigger&echo are connected to pins (5,6) on Arduino
Servo motor GND & Vcc as before and the third pin is connected to pin (~10) on Arduino
Switch is connected to pin (4) as pullup, and the other pole to the common ground.
after that everything is mounted on the enclosure and ready to work.
A common mistake I did that I forgot to make the switch PULLUP, this is very important to avoid strange behavior of the circuit.
Something I learnt from peers is to reuse any scrap material at home, this could be much easier to construct a rigid box rather than making it from scratch.