Hand sanitizer
:: this week we are required to Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component to control an action component using Code Blocks.
I searched in Instructables and Arduino Project Hub and after much confusion, I was inspired by this video about how to make an automatic hand sanitizer, so let's see what this trial will bring!
Things don't make themselves, You need some tools and smart software to be able to create your device
Software
From now on, the Tinkercad will become your new friend.
Tinkercad is used for creating digital designs that are ready to be 3D printed or to simulate electric circuits and/or code them. we will use it to simulate an electric circuit before making it in real to test wiring and avoid components burning.
This week we going to start coding but on a small scale
Arduino IDE is used for writing code and connecting with an Arduino bored to get actions done, this time we do not write code but turn the coding blocks into written code in IDE.
Electronics tools
INPUT: to measure the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal.
It has 4 terminals as shown in this figure.
OUTPUT: to move things by converting signals into rotational angular velocity
OUTPUT: to make a sound
jumper wires have 3 types male-male wires, male-female wires, and female-female wires. All of these connect two points to each other and make the circuit closed
to-use programmable open-source microcontroller board that can be integrated into a variety of electronic projects.
is used for building circuits, and demonstrating its action
you will be exposed to this program interface of Tinkercad when you decide to create a simulation circuit
the breadboard has 3 sized types, you can choose any type of them but in this project, I chose a full-size breadboard because I had more terminals of components and to make the wiring clear
after you choose the circuit button, you get free space for designing and wiring. let's get to know the buttons that make it easier to use the program:
first you will find and search for any components here
if you need to back-step or clear all steps, choose these arrows
you can color wires and make a color coding through the tap of coloring
finally after finishing the circuit wiring, start the simulation to make sure that the wiring is right or has an error
here is the final wiring, I used color coding, red for positive and black for negative. I used a servo motor as output which has 3 terminals, ground, 5V, and signal connected to Pin 12 in Arduino. the ultrasonic is used as input which is connected with ground, 5V, echo attached to Pin 11, and trigger attached to Pin 10, and a buzzer connected to Pin 13.
to take action, you have to add code for Arduino.
I used control blocks to choose the If else function, to control the actions through certain events as the object is near or far from the ultrasonic sensor
then made a comparison from Math blocks to compare the distance according to ultrasonic
select the block of input (ultrasonic sensor) and the output action(rotate servo motor) from the Output blocks by defining the angle of rotation
don't forget to add a number of pins that attach to the ultrasonic sensor and servo motor.
the code said that if your hand or anything is at a distance of 5 cm or farther from the ultrasonic sensor
the servo will rotate 90 degree
and the buzzer will work ( a warning against excessive consumption )
it waits 1 sec to repeat the order or to do another order
so the other order is if the distance is less than 5 cm
the servo will return to its origin at 0 degree
and the buzzer doesn't work
wait for 1 second to start the orders again
start the simulation, when the target object at the distance to the ultrasonic sensor is equal to 10 cm or bigger than 10 cm, the servo motor will take action of rotation, if the condition isn't applied the servo motor stops.
You can try your turn simulation circuit
firstly prepare your components:
- breadboard - ultrasonic sensor - Arduino - servo motor - male jumper wires
start matching Arduino with components in the breadboard: this photo shows the first step which is ground attached to the negative pin and 5V to the positive pin
With the buzzer, as it showed in Tinkercad, I connected components with the breadboard and Arduino through jumper wires, you can take wiring in Tinkercad as a reference to do it in real.
Without buzzer
With buzzer
I had the challenge to make the servo motor rotate when the sensor detects an object, so I made a process to make sure that the sensor was in good health by adding an LED light when the sensor detects something, it worked, so I discovered that problem wasn't in the sensor but in the motor. After a lot of trials and changing the distance to 10 cm it worked well.