This week's project is to make an electronic circuit with 2 input and 2 output
Mine will be the restricted area alarm which will give an alarm sound when u get into the restricted area
Software
open source online platform we can use it to make the circuits and simulate them before building them which will be time saving ,easier to troubleshoot and saving the parts from burning in case of false connection
Arduino IDE
an open-source software, which is used to program the Arduino boards, it is an integrated development environment, developed by
Allow to write and upload code to Arduino boards.
It consists of many libraries and a set of examples of mini-projects.
Materials
For the Electronic Circuit
Small breadboard For wiring
usb Cable to connect Arduino to the PC
Arduino
Male Wires
Resistance
Slide Switch
LED
Ultrasonic Sensor
Buzzer
This is the idea of the alarm that it has
slide switch (Input)
Ultrasonic Sensor (Input)
Red LED (Output)
yellow LED (Output)
Green LED (Output)
Buzzer (Output)
If the switch is High
the sensor has 3 levels
within the allowed area, it will light the green Led
within a closer area to the sensor, it will light up a yellow LEd which means you are moving toward a restricted area
finally, if you move toward the restricted area, it will Light up the Red LED and give a Beep sound which means you are trespassing in a restricted area
If the switch is Low, the alarm is off
First, I had to simulate the circuit on TinkerCad before wiring it
choose the objects for the circuit
Slide Switch (Input)
Ultrasonic Sensor (Input)
Arduino (Processing)
Red LED (Output)
yellow LED (Output)
Green LED (Output)
Buzzer (Output)
Connect the +ve and -ve of Arduino to the +ve and -ve of the Board
connect From the +ve of the board to 1st terminal of the switch, the -ve of the board to the 3rd terminal, and the second (middle) terminal to pin 8 of the Arduino
connect the -ve of the buzzer to the -ve of the board and +ve to pin 7 in Arduino
connect a 220-ohm resistance to the cathode of the LED and then Attached it to the board -ve Part
connect the anode of the Green LED to pin 6 in the Arduino
connect the anode of the Yellow LED to pin 5 in the Arduino
connect the anode of the Red LED to pin 4 in the Arduino
Connect the +ve of the Sensor to the Board +ve and Ground to the board -ve
attached trigger to pin 3 of the Arduino and echo to pin2
Using Arduino IDE , we will start our code
First part of the code will be defining the variables
I assigned the name and the pin number to each variable
we started the void setup by starting the serial monitor then defining the pin mode of the variables to be either input or output
Then we begin the void loop by defining the sensor and set it values in order to deal with trigger and echo pins so finally it can give us an OUTPUT in CM
after that , it begin to take input from slide switch which have 2 cases
if it's LOW, nothing will happen , the LED and Buzzer will e set to LOW so no Action will be taken
if it's HIGH, it will take another actions we will discuss later in the code
so this if condition checks the case of the switch
in this case , the input switch is set to be HIGH, so it will start checking for the other INPUT(Ultra sonic sensor)
if the sensor reads something within the range of less than or equal 50 cm , it will Light up the Green LED
If not, the LED will be set to low
in this case , the input switch is set to be HIGH and it will start checking for the other INPUT(Ultra sonic sensor)
if the sensor reads something within the range of less than or equal 20 cm , it will Light up the Yellow LED
If not, the LED will be set to LOW
in this case , the input switch is set to be HIGH and it will start checking for the other INPUT(Ultra sonic sensor)
if the sensor reads something within the range of less than or equal 5 cm , it will Light up the RED LED and Gives a buzzer sound
If not, the LED will be set to LOW
the final part of the code is the case of the range of distance is more 5 or less than or equal 0,it will print (Outside the permissible range of distances) and gives no sound
otherwise it will print the distance and gives a buzzer sound
This one is the same circuit simulated on Tinker CAD and the video below is the demonstration of the functional Circuit
one of the challenges I faced was the code defining the ultrasonic sensor
this was the code i found and when i compiled it , the feature wasn't working so i searched for the code again
this is the right code , so i made those edits to the code and it worked
i learned on how can I utilize the software Like TinkerCAD and make a simulation before wiring so we save the components from burning