Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Resistor 10k ohm
LED (generic)
Resistor 330 ohm
LDR, 5 Mohm
Standard LCD - 16x2 White on Blue
SG90 Micro-servo motor
Software & Tools
Arduino IDE
Project description
Code
The parking place management system
c_cpp
Updating soon
1#include <Wire.h> 2#include <Servo.h> 3#include <LiquidCrystal_I2C.h> 4// the libaries for 16x2 I2C is from github: 5// https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library 6 7// Set the LCD address to 0x27 for a 16 chars and 2 line display 8LiquidCrystal_I2C lcd(0x27, 16, 2); 9// Pins that recives the analoge signal from the ldr to arduino 10const int ldrPin1 = A0; 11const int ldrPin2 = A1; 12const int ldrPin3 = A2; 13const int ldrPin4 = A3; 14const int ldrPin5 = A4; 15Servo myservo; 16int re = 4; //count the car place remain 17 18void setup() { 19 // put your setup code here, to run once: 20 lcd.begin(); 21 lcd.backlight(); 22 lcd.setCursor(0,0); 23 lcd.print("Spaces available"); 24 25 myservo.attach(9); // attach the servo to our servo object 26 myservo.write(90); // set the servo motor speed to zero 27} 28void loop() { 29 // put your main code here, to run repeatedly: 30 re = 4; // update the value 31 lcd.setCursor(0,1); // set the cursor for the lcd scream to the second row 32 delay(20); 33 int ldrStatus1 = analogRead(ldrPin1); // read the value from the pin 34 int ldrStatus2 = analogRead(ldrPin2); 35 int ldrStatus3 = analogRead(ldrPin3); 36 int ldrStatus4 = analogRead(ldrPin4); 37 int ldrStatus5 = analogRead(ldrPin5); 38 39 if (ldrStatus2 < 300) { // *important: change the variable for you own ldr 40 re--; 41 } 42 if (ldrStatus3 < 300) { 43 re--; 44 } 45 if (ldrStatus4 < 300) { 46 re--; 47 } 48 if (ldrStatus5 < 300) { 49 re--; 50 } 51 if (ldrStatus1 < 300) { //check if there is car trying to enter 52 if(re == 0){ // the parking place is full 53 lcd.print(" ");// clear the screem by rewrite on it 54 lcd.setCursor(0,1); 55 lcd.print(" Bad Luck "); 56 delay(3000); // display it on the screem for 3 sec 57 lcd.setCursor(0,1); 58 lcd.print(" "); 59 } 60 else{ 61 lcd.clear(); // clear the whole screem 62 for(int i=-7; i<17; i++){ // let the message roll though the screem 63 lcd.clear(); 64 lcd.setCursor(i,0); 65 lcd.print("Welcome "); 66 delay(200); 67 } 68 myservo.write(45); // 360 degree sg90 turn clockwise 69 delay(200); // around 90 degree under this time delay 70 myservo.write(90);// stop 71 delay(5000); // wait 5 sec let the car pass 72 myservo.write(135);// 360 degree sg90 turn anticlockwise 73 delay(200); 74 myservo.write(90); 75 } 76 lcd.setCursor(0,0); 77 lcd.print("Spaces available"); 78 lcd.setCursor(0,1); 79 } 80 lcd.print(re); // print the space remain 81}
Downloadable files
The parking space
A parking space for model car
The parking space

Comments
Only logged in users can leave comments