This week’s assignment is to create a smart program controlled by an Arduino that reacts to specific sensor readings and performs a corresponding action.
My plan is to simulate a railway crossing where the barrier automatically closes when a train is detected, preventing people and cars from crossing.
Software Materials : Electronic Tools
Tinkercad
Arduino IDE
LED
Servo motor : Open/Close
Resistor 220 ohms 5V adapter
Jumper wires
Cable for Arduino Uno
IR Sensor
Breadboard
Arduino Uno
TinkerCad Project : Arduino, IR sensor, servo motor and LED
What the circuit does:
I made a simple level-crossing system using an IR sensor and a servo motor. The idea was to stop cars when a train is coming and let them pass when the way is clear.
When the sensor detects a train, the servo moves down to block the road and a red LED lights up as a warning. When no train is detected, the servo lifts the barrier so cars can pass.
Everything is powered by the Arduino, with the servo, LED, and sensor all connected neatly using the breadboard rails for 5V and ground
I started connecting the Arduino’s ground (GND) to the negative rail of the breadboard and did the same for the 5V pin by connecting it to the positive rail.
Next, I connected the IR sensor’s ground and power to the Arduino’s rails and connected its signal pin into digital pin D6. Setting it up myself helped me understand how the Arduino reads data from sensors to control the project.
Thirdly, I added two LEDs ( Green for On and Red for Off), Connected the green Led anodhe to digital pin 3 and Red to digital pin 2 and the two cathodes to the ground using resistor 320 ohm to protect from the damage.
And finally, I connected the servo’s ground and power to the Arduino’s rails and plugged its signal wire into one of the pins. Setting it up myself really helped me see how the Arduino powers and controls each part of the project.
Tinkercad Code Blocks
Using the code blocks in Tinkercad to perform the circuit, I used an if condition state for the IR sensor, if there is a movement (pin 2) HIGH, then set the motor (pin 8) to 0 degree, the LED (pin 3) to LOW, and the LED (pin 4) to HIGH.
Otherwise set the motor (pin 8) to 130 degree, the LED (pin 3) to HIGH, and the LED (pin 4) to LOW
The circuit Process
Step 1: Preparing the components needed, Here is the list of all the electronic components I will need.
Step 2: Connect the positive and negative wires from the Arduino to the breadboard to set up the power rails.
Step 3: Connect the IR sensor’s positive and negative wires to the breadboard power rails, and attach its output pin to digital pin D6 on the Arduino
Step 4: Connect two LEDs (green for ON and red for OFF). Attach the green LED’s anode to digital pin D3 and the red LED’s anode to digital pin D2. Connect both cathodes to the ground through 320 Ω resistors to protect them from damage
Step 5: Connect the servo motor’s positive and negative wires to the breadboard power rails, and attach its output pin to digital pin D8 on the Arduino
Step 6: Uploading the code into Arduino Uno
Final look
I spent three hours programming my LCD with Arduino while developing my own game. My friend Ali send me a link website to lean about coding LCD. This task challenged my problem-solving skills and tested my patience. I learned a lot about coding, debugging, and working with hardware. Overall, it was a valuable experience that improved my confidence and understanding of Arduino projects.
I watched a YouTube video in English about programming an IR sensor. The blocks in his Tinkercad were in English, but mine were in French, so the blocks looked different and I couldn’t find the ones he used. So as solution i used the tinkercad of my friend that was english and it became easy the work after.
Learning how to program components with Arduino gave me a stronger understanding of how each part works together, which I can use in my final project.
Writing code for the sensors( Ultrasonic sensor, servo motor) project showed me how programming can bring movement and life to a design.
This week felt really special compared to the others. I worked on something I never imagined I could do. It reminded me of the automatic doors and motion sensors I’ve only seen in malls or on TV
Discovering new components useful as LCD, photoresitor, servo motor