└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # SMART-CAR-PARKING-SYSTEM 2 | #include // For storing the slot status 3 | #include // For the LCD display 4 | #include // For GSM module communication 5 | 6 | // Define LCD pins 7 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 8 | 9 | // Define pins for ultrasonic sensors 10 | const int trigPin1 = 9; 11 | const int echoPin1 = 8; 12 | const int trigPin2 = 7; 13 | const int echoPin2 = 6; 14 | 15 | // Define pins for LEDs 16 | const int ledPin1Green = 10; 17 | const int ledPin1Red = 13; 18 | const int ledPin2Green = A1; 19 | const int ledPin2Red = A2; 20 | 21 | // GSM module pins and serial communication 22 | SoftwareSerial gsmSerial(2, 3); // RX, TX for GSM 23 | 24 | // Parking slot distance threshold 25 | const int distanceThreshold = 10; 26 | 27 | // Function to measure the distance using ultrasonic sensor 28 | long measureDistance(int trigPin, int echoPin) { 29 | digitalWrite(trigPin, LOW); 30 | delayMicroseconds(2); 31 | digitalWrite(trigPin, HIGH); 32 | delayMicroseconds(10); 33 | digitalWrite(trigPin, LOW); 34 | 35 | long duration = pulseIn(echoPin, HIGH); 36 | long distance = (duration * 0.034) / 2; 37 | return distance; 38 | } 39 | 40 | // Send SMS via GSM module 41 | void sendSMS(const char* message) { 42 | gsmSerial.println("AT+CMGF=1"); // Set GSM to text mode 43 | delay(100); 44 | gsmSerial.println("AT+CMGS=\"+91xxxxxxxxxx\""); // Your phone number 45 | delay(100); 46 | gsmSerial.println(message); 47 | delay(100); 48 | gsmSerial.write(26); // End the SMS 49 | delay(1000); 50 | } 51 | 52 | void setup() { 53 | // Initialize serial communication 54 | Serial.begin(9600); 55 | gsmSerial.begin(9600); 56 | 57 | // Initialize LCD 58 | lcd.begin(16, 2); 59 | 60 | // Set the pins for the ultrasonic sensors, LEDs 61 | pinMode(trigPin1, OUTPUT); 62 | pinMode(echoPin1, INPUT); 63 | pinMode(trigPin2, OUTPUT); 64 | pinMode(echoPin2, INPUT); 65 | 66 | pinMode(ledPin1Green, OUTPUT); 67 | pinMode(ledPin1Red, OUTPUT); 68 | pinMode(ledPin2Green, OUTPUT); 69 | pinMode(ledPin2Red, OUTPUT); 70 | 71 | // Display initial message on LCD 72 | lcd.setCursor(0, 0); 73 | lcd.print("Parking System"); 74 | delay(2000); 75 | lcd.clear(); 76 | } 77 | 78 | void loop() { 79 | // Measure distance for parking slot 1 80 | long distance1 = measureDistance(trigPin1, echoPin1); 81 | long distance2 = measureDistance(trigPin2, echoPin2); 82 | 83 | // Check slot 1 availability and update LEDs 84 | if (distance1 < distanceThreshold) { 85 | digitalWrite(ledPin1Red, HIGH); 86 | digitalWrite(ledPin1Green, LOW); 87 | lcd.setCursor(0, 0); 88 | lcd.print("Slot 1: OCCUPIED "); 89 | EEPROM.write(0, 1); // Store slot 1 status 90 | } else { 91 | digitalWrite(ledPin1Green, HIGH); 92 | digitalWrite(ledPin1Red, LOW); 93 | lcd.setCursor(0, 0); 94 | lcd.print("Slot 1: AVAILABLE"); 95 | EEPROM.write(0, 0); // Store slot 1 status 96 | } 97 | 98 | // Check slot 2 availability and update LEDs 99 | if (distance2 < distanceThreshold) { 100 | digitalWrite(ledPin2Red, HIGH); 101 | digitalWrite(ledPin2Green, LOW); 102 | lcd.setCursor(0, 1); 103 | lcd.print("Slot 2: OCCUPIED "); 104 | EEPROM.write(1, 1); // Sto 105 | --------------------------------------------------------------------------------