Make a Wavebot Using Ultrasonic Sensor and Servo Motor

by lwu22 in Circuits > Arduino

305 Views, 3 Favorites, 0 Comments

Make a Wavebot Using Ultrasonic Sensor and Servo Motor

IMG_4619.jpeg

This is a "wavebot" that can wave when it detects something within a certain distance. This is made by using ultrasonic sensor and servo motor using Arduino Uno. It is quite easy to make, and you can see how it looks and acts by watching the video to get started.

Supplies

IMG_4635.jpeg

Electronics:

  1. Arduino Uno*
  2. Breadboard Small(as small as possible)
  3. Connecting Wires
  4. Cables to connect Arduino with personal device(need USB-C Adaptor if your device only accept type-C)
  5. Micro Servo motor
  6. HC-SR04 Ultrasonic Distance Sensor*

* = The material is still required even though it is not shown on the picture.

Tools:

  1. Hot glue gun and hot glue stick
  2. At least 2 tiny finger hand puppet
  3. Exacto knife
  4. Tape
  5. 4 x 4 inch cardboard box(could be replaced with any other box).

Design the Circuit

Brilliant Juttuli-Borwo-2.png
Screenshot 2023-12-10 at 1.27.02 AM.png
Screenshot 2023-12-10 at 1.27.25 AM.png
Screenshot 2023-12-10 at 1.27.35 AM.png

This picture is made using Tinkercad, and it shows ways to assemble the Arduino circuit. Make sure that you understood how it works before actually assembling it. Connect the parts together through using the connecting wires. The ultrasonic distance sensor will be attached to the breadboard, while the Arduino and servo motor will be on their own. The ultrasonic distance sensor and servo motor will be connecting to different power, 3.3V and 5V. Below is a guide that shows you how to different wires in the picture and their corresponding digital pin on Arduino. Make sure that you read them along with the picture.

Connecting servo motor to Arduino

1. left wire(red) to 5V pin on Arduino.

2. middle wire (white) to digital pin 7 on Arduino

3. right wire(black) to GND pin on Arduino.

Connecting ultrasonic distance sensor to Arduino

1. VCC pin on sensor(green) to 3.3V pin on Arduino.

2. Trig pin on sensor(blue) to digital pin 9 on Arduino

3. Echo pin on sensor(yellow) to digital pin 8 on Arduino

4. GND pin on sensor(orange) to GND pin on Arduino

Assembling the Electronics

IMG_4601.jpeg
IMG_4605.jpeg

After understanding the circuit, now it's time to assemble the Arduino, servo motor and ultrasonic distance sensor using the picture in Step 1. Ignoring the puppet hand for now, make sure the circuit looked similar to the circuit in the first picture. It will be a lot more convenient later if you attached the sensor on the side of the breadboard that has no bumps.

After that, glue your first puppet hand onto the blade that comes with the servo motor(any size of the blade will do, but longer blades will be more convenient) using hot glue gun, as shown in the first picture. Be careful, the puppet hand might melt a little and burn your fingers. It will take sometime for the hand to be secured onto the blade, so make sure that you hold the puppet hands before the glue dries out. This will be used to test the wavebot in the next step.

Now use the hot glue gun again to glue the Arduino with the breadboard, as shown in the second picture. Make sure that they are glued securely together just like the orientation in the second picture: sensor facing the front, USB port facing left.

Arduino Programming

Now it's the time to test your Arduino circuit! You can copy and paste the code below into your Arduino IDE, and then upload the code onto the Arduino to test if the code works. Don't forget to import the servo library! If it works, the servo motor should be activated and rotate when something is around 10~30 cm in front of the ultrasonic sensor. If it doesn't work, check if you have pasted the wrong code or assembled the circuit in a wrong way. Make sure to press "upload" on Arduino IDE to save the code onto the Arduino.

Copy and paste the following code:


#include <Servo.h>


Servo servo1;

const int trigPin = 9;

const int echoPin = 8;

const int servoPin = 7;

long distance;

long duration;

void setup()

{

servo1.attach(servoPin);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

}

void loop()

{

ultra_sonic();

servo1.write(45);

//you can customize the distance yourself

if (distance > 10 && distance <= 30){

servo1.write(270);

delay(1000);

servo1.write(270);

delay(1000);

servo1.write(270);

delay(1000);

servo1.write(45); //you can also customize the wavebot's action yourself.

}

}

void ultra_sonic()

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration*0.034/2;

delay(100);

}

Carving the Cardboard Box

IMG_4611.jpeg
IMG_4610.jpeg
IMG_4609.jpeg
IMG_3625.jpg

Now it's time to assemble all the pieces together! First, you will need to cut out several holes on the cardboard box using the Exacto knife. This is because the circuit need to be hidden into box, but the sensor need to be outside of the box to make sure that it detects objects outside of the box, the USB port need to be outside the box to be able to connect to power source, and the motor blade need to the outside so that the hand puppets could be seen. When making the hole, use the forth picture as reference on where the hole should be. The motor and the sensor could also be on the same side if you make sure that the hands won't cover the sensor. You can take the blade off first to make it more convenient. You might need to adjust the size of the hole several times, especially the hole of the servo motor to make sure that the blade stays attached to the motor.

Assembling the Box

IMG_4612.jpeg

After carving out the holes on the box, attach the Arduino, sensor and servo motor to corresponding holes on the box using hot glue gun. Make sure that the USB serial port, sensor, and the blade on motor went through the hole and went outside of the box, just like the pictures in Step 4. Now the inside of the box should look like the picture in Step 5, and the outside should look like pictures in step 4. Make sure that they are all secured in the box, and connect the USB port with a power source to test the wavebot.

Adding the Hands

IMG_4615.jpeg
IMG_4619.jpeg

Now the major mechanics of the wavebot is done. Feel free to continue glueing hands on to the blades, or decorate the cardboard box in to the ways you like. The wavebot is done! As long as you plug the bot into a power source, it will work and wave to people when they passed by the wavebot. You can also use the tape to seal the box to make it look better. Thank you for reading!