Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component (Sensor, Switch, or variable resistor) to control an action component (Motor, Buzzer, LED...etc) using Code Blocks
Automatic Doors
We can simulate the way automatic doors work by connecting the servo motor to the infrared sensor and programming them.
Tinkercad to design the circuit
Arduino to upload the code
9V adaptor
Arduino uno and usb
Jumper Wire
servo motor
IR sensor
STEP 1
I designed my circuit on Tinkercad.
I used the servo Motor as the output component and the IR sensor as the input component.
I used 9V as a power source.
I used Arduino Uno as a controller.
I used an IR sensor as input.
I used a servo motor as an output.
I simulate the circuit on Tinkercad.
when the sensor detects movement the motor rotates 90 degrees.
STEP 2
I need to:
when the sensor detects movement the motor rotates 90 degrees.
To do that in simulation:
I use blocks to program it.
I use the "if" condition to control the program.
I use Math conditions to compare the sensor's reading to see if it is HAIGH or LOW.
I use a rotate servo condition to determine the angle of movement of the motor.
finally, I use the rotate servo condition as the output condition to determine the servo angle when if condition is not achieved.
I put a delay for Socund.
STEP 1
After testing the components, I connected the circuit individually to test it.
I prepare the component to be ready to connect with instruction and other components.
I connect the servo with Arduino as one-on 5V, one-on GND, and the third with a digital pen NO(9).
I connect the sensor as same as the motor but with digital pen NO(8).
STEP 2
I copied the code from Tinker Cad and pasted it into Arduino software.
I edited the code by replacing HIGH with LOW.
I loaded the code to my Arduino board.
when I connected the circuit and uploaded the code that I copied from Tinkercad it did not work.
After researching, I discovered that the sensor on Tinkercad is positive, so when it senses movement it gives a signal and it is high, but the sensor I have is negative when it senses movement it is low.
I edited it on Arduino software.
Arduino code
I understood how sensors work and react with Arduino and other components in circuits and how could I turn my orders into blocks.
With my best teammate Dina, We could make and program this prototype with Arduino.
I navigated her to simulate this circuit and I made the model a reality.
she made another one which I simulated and it was perfect.
Hani say HI😅