Ideation
This week's idea is to create a smart program controlled by the Arduino, which receives a specific reading and then does a specific thing.
My idea for this week is to simulate a railway crossing, the barrier is closed when the train is sensed approaching to prevent people from crossing.
I will use Tinkercad to simulate the circuit before you send it to the breadboard
I will use the Arduino IDE to upload the code to the Arduino
For the electrical circuit
Jumper Wires.
Arduino
IR Sensor
Resistor 220: For the LED.
Servo Motor to open and close
Small breadboard: To connect the circuit.
Adaptor 9V :The source of electricity.
I will use 2 LED one red to light up when the barrier is closed, and the other green to light up when the barrier is opened.
The idea of my project is that the servo motor moves to block the road when the sensor senses a movement at a certain distance.
I started connecting the negative of the Arduino to the vertical lines of the board and did the same for the power.
Then I connected the negative and positive of the servo motor to the negative and positive of the Arduino on the board, and connected the third terminal to one of the Arduino pins to control the motor via the Arduino.
Thirdly, I connected the PIR sensor instead of the IR sensor to simulate the circuit, which was connected similarly to the servo motor, the negative to the negative and the positive to the positive, and the third terminal to one of the Arduino pins. I will use the IR sensor.
Fourth, I connected two LEDs, one red to light up when the barrier is closed, and the other green to light up when the barrier is opened.
I connected the positive of the LED to one of the Arduino pins and connected the negative to the negative of the Arduino on the board, but not directly. I connected a resistor before it to protect the LED from damage.
Tinkercad Blocks
Simulating circuit
Using the code blocks in Tinkercad to perform the circuit, I used an if condition for the IR sensor, if there is movement (pin 2) HIGH, then set the motor (pin 8) to 0, the LED (pin 3) to LOW, and the LED (pin 4) to HIGH.
Otherwise set the motor (pin 8) to 130, the LED (pin 3) to HIGH, and the LED (pin 4) to LOW
Here are all the electronics I will need.
I started by connecting a positive and negative wire from the Arduino to the board.
I had connected the negative of the LED so I connected two wires to each positive of the LED from the pins I specified in the code.
Then I connected the servo motor with a wire to the negative and another to the positive of the Arduino and the third to the pin that I chose.
Then I connected the sensor in the same way and the third leg with a different pin I chose in the code
I had already uploaded the code to the Arduino, so I used the adapter to connect the electricity.
And here is my final outcome
Working with my teammate Sameh to do the task of the week helped me a lot.
The problem I faced this week was that after I connected the circuit to the board and to the Arduino, the IR sensor did not work, so I started to check the connections to make sure if everything was connected correctly, and it was connected correctly, so I checked the code to make sure, but it was correct as well. The last solution I thought of was that maybe there was a wire that was not working or something, so I brought the Avometer and started to check all the wires and components, and it turned out that one of the sensor wires was not working from the beginning, so I replaced it with another one, and yes, it worked.
What I learned this week helped me a lot, and clarified many things that I will need in my final project.
Makers ✨
I designed and programmed this circuit, you can check it out