Touchless Door Opener

by Random Stuff We Make in Teachers > Arduino

411 Views, 2 Favorites, 0 Comments

Touchless Door Opener

ezgif.com-gif-maker (8).gif

This is a simple project to teach basic usage of Ultrasonic sensor with Servo motor to kids. The project is simple in terms of code, circuit & implementation.

Material Required

IMG_0521.jpg
ultrasonic-sensor-500x500.jpg
Arduino-Nano-V3.jpg

  • Arduino Nano/Uno/Mini
  • SG-90 Servo motor
  • HC-SR04 Ultrasonic sensor
  • Jumper Cables

Making the Connections

Touchless Door_bb.png

There are only a few connections to be made, follow the steps below:

  • Attach the Arduino board to a breadboard.
  • Connect 5v & GND to the side power rails of the breadboard.
  • Connect the VCC & GND of Servo motor & Ultrasonic sensor to the power rails.
  • Connect the Orange wire(Signal) of the Servo motor to pin 9 of Arduino.
  • Connect the Trigger pin of the Ultrasonic sensor to pin 10 of Arduino.
  • Connect the Echo pin of the Ultrasonic sensor to pin 11 of Arduino.

Let's Code

Screenshot (53).png

Explanation: This code uses the simple Servo library.

  • Four variables were declared initially.
  • In the setup part, the Servo pin is declared as 9. Trigger pin is declared as output & Echo pin is declared as input.
  • In the Loop section, a function named Ultra was called & then the servo was made to rotate for 0 degrees.
  • If Case checks the presence of the hand in front of ultrasonic sensor & hence rotate the servo to 90 degrees.