Automatic Dispenser

by ilyas.alam in Craft > Cardboard

153 Views, 1 Favorites, 0 Comments

Automatic Dispenser

63DA62AF-C4D3-4F41-B559-356445E64C4D (1).jpeg
trim CE30E60C 2326 4CB4 AE24 A04053DA44CB+1 1

This dispenser can dispense objects that are being stored. It is portable, cheap, and efficient and can help improve lives of many people.

Supplies

Cardboard box

Arduino

Jumper wires

Ultrasonic sensor

Micro-servo motor

Velcro

tape

Tennis Ball(can be any other object)

Cutting the Box

Take the box and make a hole in the bottom big enough to fit your chosen object.

Make 2 holes where the ultrasonic sensor will be placed.

Screen Shot 2021-05-24 at 2.15.38 PM.png

Connect the Arduino, servo motor, and ultrasonic sensor with jumper wires according to the image.

Bread board is not necessary.

Putting Everything Together

Tape arduino to box and tape ultrasonic sensor to fit into the two holes. Tape popsicle sticks to servo motor and velcro the servo motor to the box.

Optional Information

Can paint the box to make it look better.

Code for Arduino: #include

Servo servo1; int trigPin = 9; int echoPin = 8; long distance; long duration;

void setup() { servo1.attach(7); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);// put your setup code here, to run once: }

void loop() { ultra_sonic(); servo1.write(90); if(distance <=9) { servo1.write(270); } }

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; }

Code was adapted from https://techtermite.blogspot.com/2020/04/using-ser...