Smart Garage
So, for this week I decided to continue with the smart garage but add more features. What happens is that I have 2 IR sensors: one to check if there’s any car outside to open the door, and another sensor inside to check if there’s any car that wants to get out, so the door opens as well. This week’s extra feature is a 7-segment display that can show us how many available slots there are.
Tinkercad → A website where we can design and simulate electronic circuits, allowing us to test and make sure they work before applying them in real life!!
Arduino → The big boss, used as our brain for control.
Breadboard → The playground for connecting and testing components 😎.
Jumper Wires → Used to connect components together.
Servo Motors 180 degreses→ Control the angle of the door(Output component).
IR Sensor → Checks if something is cutting the radiation(Input Component).
Push Button → Updates the 7-segment display(Input component).
7-Segment Display → Shows numbers from 0 to 9 for the available slots(Output component).
Smart Garage Simulation Circuit
✨ Step 1: Bringing players to the playground
I gathered all my electronic “players” onto the breadboard: 2 PIR sensors, a servo motor, and an Arduino Uno. Time for the match to begin!
✨ Step 2: Connectionssss
First, I started by connecting the Arduino 5V to the red line of the breadboard and the GND to the black line.
Then I wanted to connect the IR sensor, but in Tinkercad the one that works is the PIR sensor—same idea and everything. I connected the signal pins to digital pins 2 and 3, GND to the black line, and power to the red line.
I connected the servo motor: the signal to digital pin 4, GND to the black line, and power to the red line.I also added th push button and the 7-segment display.
✨ Step 3: Coding
For the code, if one of the sensors reads (using the OR condition) → turn the servo 90 degrees. By default, it stays at 0 degrees as mentioned in the first line and another if condition to add and subtract the available slots, switch case to conver the int to display, and functions for all numbers of the 7 segment display.
Defining pins
Labeling pins pinMode
First Sensor reading and counting
Second Sensor reading and counting
7-Segment displaying current available slots
Numbers functions for the 7-segment display
I started by connecting the wires as mentioned in Tinkercad, and placing the 2 sensors separately so I could test them. And as you can see in the video below, it worked just perfect.
So my first challenge was that while the sensor was reading, the available slots kept counting down or up. Then I decided to modify it by adding prevRead and current so it only counts once.
But another problem appeared—the motor didn’t have enough time to work properly. So I decided to make them two separate if conditions: one for the count and another for working the servo motor.
Title of Media
Title of Media
Title of Media