I was inspired by the barrier gate.
It is easy to replicate it using a servo motor and ultrasonic sensor.
Software
I used Tinker CAD to design the circuit and to simulate the text code.
I used Arduino IDE to upload the text code on the Arduino UNO board.
Electronic components
3- 220-ohm Resistor / RGB LED
Adjusts the current passing through the RGB LED, which is going to indicate the gate open/closed
Jumper wires
Connecting the components.
Breadboard
To fix the components in and connects them together.
Arduino UNO board
will be connected to the inputs and the outputs and power them. It is also going to run the code on the components.
Ultrasonic sensor
Is going to be our input, when it senses a person or an object, the output component is going to work
Servo Motor
will resemble the gate door responding to the ultrasonic sensor
Push Button
to open the gate with the manual mode
Slider Switch
to switch between manual and automatic mode.
The circuit on TinkerCad
RGB LED connected to pin 4, pin 3, and pin 5
Ultrasonic sensor trig connected to pin 6
echo connected to pin 7
Servo Motor connected to pin 9
Slider switch connected to pin12
Push Button connected to pin 11
In this simulation
Ultrasonic sensor is an Input.
Slider switch is an Input.
Switch button is an Input.
RGB LED is an Output.
Servo motor is an Output.
Automatic Mode:
When an object is 50 cm far or less from the Ultrasonic sensor, the servo motor opens to 90 degrees, and the light turns green, if not the servo stays 0 degrees and the light is red.
Manual Mode:
When you push the button, the servo motor opens to 90 degrees and the light turns green, when the button is released the servo stays 0 degrees and the light is red.
You can switch between the two Modes through the slider switch.
I started coding on Arduino IDE with the Arduino-Ultrasonic Sensor-Servo Motor project code. This project already had the Ultrasonic Sensor controlling the servo motor. I had to add the RGB LED output then the slider switch and the push button to have an automatic and a manual mode
I tested the final code on TinkerCad and it worked with both the manual and the automatic mode.
I wired everything with the actual components, uploaded the code and it worked.
Throughout this week I struggled with coding and thought I could never do it.
I took a break from the assignment and after a second look, I realized the problem was wrong wiring with the slider switch.
Re-checking the end-of-week session activity, I followed the steps of switching between manual and automatic modes, after correcting the wiring of course, and it went well.
Wrong wiring of slider switch
After the code was done, I found the servo motor making a noise but not moving, I thought it was broken. I asked my instructor and he suggested powering the servo motor with a 5V adapter and connecting the ground of the adapter and the Arduino and it worked perfectly.
This week made me more comfortable with coding and thinking of the steps in simpler ways to make the project happen. This will definitely help with making the final project exceptional.
{
Learning how to use this program is exaptational. I never thought I could be able to write code and it never crossed my mind that if I tried I would succeed;
Learning about the open-source community and how easy it would be to find similar codes for your project and build on it to get the desired outcome;
}
Arduino IDE
Title of Media