This week's project is to make an electronic circuit with 1 input and one output
Mine will be the parking gate which is opened when the security pushes the button so the motor takes a signal and opens the gate
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
Push Botton
Servo Motor
This is the idea of the parking gate
where we can find the motor rising the gate when the signal is taken from the push button
First, I had to simulate the circuit on TinkerCad before wiring it
choose the objects for the circuit
push button
Arduino
stepper motor
Resistance
started to wire the components
connected the 5 Volt and Ground Terminals of the Arduino to the breadboard
2. Connected the stepper motor
it has 3 terminals
5v volt of the motor to the 5v from the breadboard
Ground of the motor to the ground of the breadboard
signal of the motor to Digital pin 3 of the Arduino
3. connected the first terminal of the push button to the +ve of the board and the other terminal to digital PIN 2 of the Arduino
4. Make a connection between the second terminal of the push button and the ground by adding 2 k resistance in parallel to it to be a pull-up resistance (to avoid floating status)
5. wrote the code using code blocks
This is the Code written in C
Could you let me know what this code does?
This circuit is simple, it consists of an input(Push button)
When the button is pressed it makes the servomotor (Output)
rotate by a certain angle
To make Arduino take the input, and process it to give us the output we have to write this code
Include the library of servo so the Arduino can deal with it
Name the servo so we can deal with it later and
define the input PIN 2 (push button) and output action(servo)
Attach Servo to PIN 4 and gave it the range of Values
make the Arduino read from the input (Button ) process the info received and then give the output (Movement of servo )
if it takes 1 (button is pressed ), Arduino gives the order to the servo to move by 90 degree
if it takes 0 (button is unpressed ), Arduino gives the order to the servo to move back to the 0 degree
We can take it from Tinkercad but this code has to be tweaked for the input to be INPUT_PULLUP instead of INPUT to be working functionally
we took the code and edited it on Arduino IDE
and now it's ready to go
1. connected the 5 volt and ground of the arduino to the board
2. attached the Push Button to the Board
2. connected the first terminal of the Pushbutton to the +ve of the board and the other terminal to PIN 2 in the Arduino
3. connected the motor 5v and ground to the board and took the signal pin to the Arduino PIN 4
4. connected the Arduino to the PC and uploaded the code
one of the challenges I faced was that I made the circuit without pull up resistor so the servo was having a sudden movement without pushing the button
the instructor told me that ii have to use a pull up resistor
i learned on how can I utilize the software Like TinkerCAD and make a simulation before wiring so we save the components from burning