list of products from Amazon (Not mine, i just link them!) Scroll Down For Article! Note: Elegoo boards are not Arduino, but they are compatible with Arduino IDE and are mutch more affordable!
Building a Smart Parking System with Arduino
Smart parking systems are innovative solutions that use sensors and microcontrollers to detect and display parking availability. This article explains how to build a basic smart parking system using Arduino, sensors, and an LCD display.
Components Used
- Arduino Microcontroller: Serves as the brain of the system.
- LCD Display (16x2): Displays the parking space statuses.
- LED Indicator: Lights up if all parking spaces are occupied.
- Two Digital Sensors: Detect whether parking spaces P1 and P2 are occupied or free.
- Wires and Resistors: For connections.
Hardware Connections
- LCD Connection: The
LiquidCrystal
library initializes an LCD object connected to digital pins2-12
. Each pin serves a specific purpose, such as data or control signals. - LED Pin: Connected to pin
13
for visual alerts when parking spaces are full. - Sensors: Connected to pins
6
and0
. Each sensor reads the state of a parking spot (HIGH
for occupied,LOW
for free).
Understanding the Code
Libraries and Variables
#include <Wire.h>
and#include <LiquidCrystal.h>
: Libraries for I2C communication and LCD control.- Variables
p1
andp2
: Represent the pins connected to parking sensors. THRESHOLD
: Placeholder for possible future extensions, e.g., temperature monitoring.
Setup Phase
The setup()
function configures:
- Pin Modes:
pinMode(13, OUTPUT)
: Sets the LED as an output.pinMode(p1, INPUT)
andpinMode(p2, INPUT)
: Configure parking sensors as inputs.
- LCD Initialization: Activates the LCD with a 16x2 configuration.
- Serial Communication: Initializes the serial monitor for debugging.
Main Logic in loop()
- Read Sensor States:
pl1 = digitalRead(p1)
: Reads the state of parking spot 1.pl2 = digitalRead(p2)
: Reads the state of parking spot 2.
- Update LCD:
- Displays "Free" if the sensor reads
LOW
. - Displays "Full" if the sensor reads
HIGH
.
- Displays "Free" if the sensor reads
- LED Control:
- If both spots are occupied (
pl1 * pl2 == 1
), the LED lights up. Otherwise, it remains off.
- If both spots are occupied (
- Delay:
- Introduces a 500ms delay to avoid flickering.
Key Features of the System
- Real-Time Updates:
- LCD displays the status of parking spots in real-time.
- Alert System:
- An LED warns when both parking spaces are occupied.
- Efficient Logic:
- Uses simple conditional checks to toggle display and LED.
How It Works
- Initial State: The system starts by initializing the LCD and sensors.
- Parking Spot Status:
- Sensors connected to
p1
andp2
detect vehicles in the respective parking spots. - The LCD displays "P1 Free" or "P1 Full" for parking spot 1, and similarly for parking spot 2.
- Sensors connected to
- LED Alert:
- Lights up when both parking spots are occupied.
Future Enhancements
- Add More Sensors: To accommodate additional parking spaces.
- Remote Monitoring: Use Wi-Fi or Bluetooth to transmit parking status to a smartphone app.
- Expand Display: Show additional information such as the number of free spots.
By understanding and implementing this code, you can create a basic yet effective smart parking system. This project is a great starting point for learning about microcontrollers and embedded systems.
0 Comments