Hey everyone!
Sorry I have not posted in a while. Today I will be teaching you how to make a secured car parking system using Arduino. This system can be used for your personal garage. This project took me upto one week for completion. Every time I tried this project with the same codes, it worked differently. The malfunction was caused due to faulty jumper cables. Read on further to learn how I did this project.
Hardware components used in this project
- Arduino Uno
- USB Type A/B cable (for Arduino Uno)
- Solderless Breadboard - Half+
- Breadboard power supply module
- MFRC522 RFID reader
- RFID tags (x2) - Card and Key tag
- Tower pro Servo motor - SG-90
- 4 digit seven segment display module - 4 pins
- LEDs (x3) - White
- LCD display module with I2C interface - 16x2
- Relay module - 5V single channel
- IR tracking sensor
- Male-to-Male Jumper wires - 10cm
- Female-to-Male Jumper wires - 20cm
Setup
Your setup must look somewhat similar to the one in the images above.
Connections
MFRC522 RFID reader
- SDA/SS - D10
- SCK - D13
- MOSI - D11
- MISO - D12
- IRQ - Not connected
- GND - Ground
- RST/ RESET - D9
- 3.3V - 3.3V
LCD display module with I2C interface
- GND - Ground
- VCC - 5V
- SDA - A4
- SCK - A5
4 digit seven segment display module
- CLK - D2
- DIO - D3
- GND - Ground
- VCC - 5V
Servo motor SG-90
- S (Orange/ Yellow wire) - S5
- (+) (Red wire) - 5V
- (-) (Black/ Brown wire) - Ground (GND)
Relay module - 5V single channel
- S - D6
- (+) - 5V
- (-) - Ground (GND)
IR tracking sensor
- S - D4
- (+) - 5V
- (-) - Ground (GND)
Coding
You will be needing the 'TM1637' library by Avishay Orpaz to control your 4 digit seven segment display module, 'Arduino LiquidCrystal I2C library' to control your LCD display module, 'MFRC522' library by miguelbalboa to control your MFRC522 RFID reader and, the in-built library, 'Servo' to control your Servo motor in this project.
Follow this tutorial to learn about controlling 4 digit seven segment display module, before continuing this coding section. Create MFRC522 interface, Servo object and TM1637 display object. Set the LCD address to 0x27 for a 16 chars and 2 line display. You can use the I2C scanner to get the address of your LCD display module. Create global variables for sensor, count, value and relay. Assign the count variable to 15. Create arrays for each count to make the 4 digit seven segment display module function as a countdown timer. Please watch the YouTube video in the last section of this page to see how this project works.
Within void setup( ), set the data rate in 9600 bauds for serial data transmission. Use pinMode( ) function to configure the pins of relay module and IR tracking sensor as OUTPUT and INPUT respectively. Initiate LCD, MFRC522 and SPI bus. Use attach( ) function with your servo object as the syntax to declare the pin to which the Servo motor is connected. Use setCursor( ) function to print 'Welcome!' in the fourth column.
Within void loop( ), use lcd.clear( ) function after one second delay to clear the display so that you can print 'Keep your card' in the first row and 'here' in the second row.
Use these codes from DumpInfo sketch in the Examples from MFRC522 library.
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
If the authorised tag is placed in front of the MFRC522 RFID reader, the servo should rotate 140 degrees, the relay pin should be set HIGH and the value stored in the val variable should be assigned as 1. The lcd should show 'Access Granted'. If the unauthorised tag is placed, the servo should rotate to its initial position, the relay pin should be set LOW, the value stored in the val variable should be assigned as 0, and the lcd should show 'Access denied'. If the value stored in the val variable is 1, the value stored in the count variable must decrease by 1, or else, the count variable must be assigned to 0.
Use switch...case( ) function to set the display for each value stored in count variable. The sensor sends a LOW signal if it detects an object within few cm away from the IR transmitter and receiver. If the sensor sends a LOW signal to the Arduino microcontroller, the count variable must be assigned to 0 and the servo must be set to its original position to close the barricade. If the count is 0, the 4 digit seven segment display module must show Stop, the servo motor must be set to its initial position, and after 3 seconds, the display should be cleared and the count must be assigned to 15.
If anyone has any questions with the coding, please feel free to comment below or contact me at arduinoprojectsbyr@gmail.com.
Final Look
If anyone has any questions, or suggestions, with this project, please feel free to comment below or send me an email at arduinoprojectsbyr@gmail.com.
Comments
Post a Comment