No-Touch Lid

by kpuri in Circuits > Arduino

50 Views, 1 Favorites, 0 Comments

No-Touch Lid

IMG_4378.jpg

As a part of my college engineering class, we made a no-touch lid in order to evaluate our knowledge of circuits. This no-touch lid involves the usage of an SR04 ultrasonic sensor and an SG90 motor.

Supplies

15569-Ultrasonic_Distance_Sensor_-_HC-SR04-01a.jpg
Servo_Motor.jpg
51-CFFGSV7L._AC_.jpg
  • Foam board
  • Exacto knife
  • Ruler
  • Hot glue gun
  • SR04 sonic detector
  • SG90 motor
  • breadboard
  • UNO R3 controller board
  • USB cable
  • Computer
  • 9 jumper wires (4 male-to-female; 5 male-to-male)
  • Scissors
  • Duct tape

Create Your Box

IMG_4381.jpg

Using your foam board and a ruler, measure out SIX 5inx5in squares.

Then, cut out each square using an exacto knife on a safe surface.

Assemble Your Box

IMG_4382.jpg

Once you have cut out all 6 squares, you will need to assemble them into a cube shape.

One square will be your base.

Use your hot glue gun to glue one square on each side of your base. Make sure to glue the sides together too for more support.

Your final square will be the "lid" for your box. DO NOT use hot glue to attach it to the box. Instead use tape to tape the final square onto the cube, only putting tape on one side. This way you can open and close your box.

Write Your Code

openAI-chat-gpt-1.jpg

Using your computer, find the Chat GPT website. If you haven't already, you'll need to sign up for this site; it is free. Copy and paste this message into Chat GPT and hit ENTER:

"Write a program that uses arduino ide, using an SR04 sonic detector and an SG90 motor with arduino uno. When an object is detected 5 inches or less, rotate the servo 90 degrees and when the object disappears, rotate the servo back to zero degrees."

Save the code it gives you for later!

Set Up Your SG90 Motor

IMG_4375.jpg
SG90-servo-pin-diagram.jpg
elegoo-uno-r3-controller-board-624860-en.jpg
12002-Breadboard_-_Self-Adhesive__White_-03.jpg

For this step you will need your computer, UNO R3 controller board, SG90 motor, USB cable, breadboard, and jumper wires.

Begin by connecting your UNO R3 controller board to your computer. Plug your USB cable into your computer and attach the other end of the cable to the controller board.

Now it is time to wire your SG90 motor. On the motor you will see there is a little white bump on the top. This is where you will attach one of your propellers as seen in the picture. You will also notice that there are 3 wires coming from the motor: a red wire, a brown wire, and an orange wire.

For the following steps, refer to the picture.

  • Begin by taking a BLACK male-to-male jumper wire and attaching it to the BROWN wire coming from the motor. Attach the other end of the jumper wire to the blue line on your breadboard.


  • Then take a RED male-to-male jumper wire and attach it to the RED wire coming from the motor. Attach the other end of the jumper wire to the red line on your breadboard.


  • Now, take an ORANGE male-to-male jumper wire and attach it to the ORANGE wire coming from the motor. Attach the other end of the jumper wire to the number 9 pin on your UNO R3 controller board.

Set Up Your SR04 Ultrasonic Sensor

IMG_4376.jpg
images.jpg
elegoo-uno-r3-controller-board-624860-en.jpg
12002-Breadboard_-_Self-Adhesive__White_-03.jpg

For this step you will need your computer, UNO R3 controller board, SG90 motor, USB cable, breadboard, jumper wires, and wired SG90 motor.

Using the same breadboard and controller board, you will now wire your SR04 ultrasonic sensor. On the sensor you will notice there are 4 prongs attached to the sensor. They are labeled Vcc, Trig, Echo, and GND.

For the following steps, refer to the picture:

  • Begin by taking an ORANGE male-to-female jumper wire and attaching the female end to the Vcc prong on your sensor. Attach the male end of the jumper wire to the red line on your breadboard.


  • Next, take a YELLOW male-to-female jumper wire and attach the female end to the Trig prong on your sensor. Attach the male end of the jumper wire to the number 2 pin on your controller board.


  • Then take a RED male-to-female jumper wire and attach the female end to the Echo prong on your sensor. Attach the male end of the jumper wire to the number 3 pin on your controller board.


  • Now take a PURPLE male-to-female jumper wire and attach the female end to the GND prong on your sensor. Attach the male end of the jumper wire to the GND pin on the RIGHT side of your controller board. (refer to picture)


  • Take a RED male-to-male jumper wire and attach one end to the 5V (5 volts) pin on your controller board and the other end to the red line on your breadboard.


  • Take a BLACK male-to-male jumper wire and attach one end to the GND pin on the LEFT side of your controller board and the other end to the blue line on your breadboard.

Put It All Together!

IMG_4387.jpg
IMG_4386.jpg
IMG_4388.jpg

In order for the no-touch lid to work, you'll need to attach the sensor and the motor to your box.

Using an exactor knife, cut out a small hole in the top of your box, large enough for your motor. Refer to the picture as a reference.

Then fit your motor into the hole and tape it down to ensure it is secure.

Next, you will attach your sensor to the FRONT of your box. Simply tape the sensor to the front of the box in a way that ensures it is slightly angled upwards. This should occur naturally due to the little spikes on the back of the sensor. Again, refer to the pictures.

Upload Your Code

IMG_4378.jpg
Screenshot (51).png
ch3-buttons-labelled.png

Open Arduino IDE on your computer and open a new sketch. Delete any preexisting code on the new sketch.

Go back to the code you received from Chat GPT. Copy your code and paste it onto your arduino sketch.

Click the upload button in the top left corner and watch your no-touch lid come to life!