Kristen BinkleyGreta Powell
Published © GPL3+

Group 21- Parking Sensor

A parking sensor that can let drivers know when a parking lot is full or has vacancies.

IntermediateFull instructions provided8 hours23
Group 21- Parking Sensor

Things used in this project

Hardware components

Argon
Particle Argon
×2
LED (generic)
LED (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

"Home base" schematic

"Parking lot" schematic

Code

Parking Lot code

C/C++
double in;
bool parkingAvailable;
long duration;

int timerLED = D2;
int trigPin = D6;
int echoPin = D7;

void setup() 
{
    pinMode(timerLED, OUTPUT);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    Particle.subscribe("parkingJob", timeLimit);
}

void loop() 
{
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH);
    in = (duration/2)/74;
    Serial.print(in);
    Serial.println("inches");
    delay(200);
    // check if there is a car parked
    if (in <= 10){
        Particle.publish("unavailable", String(parkingAvailable));
        parkingAvailable = false;   
        Serial.println("unavailable");
    }
    else if (in >= 10){
        Particle.publish("available", String(parkingAvailable));
        parkingAvailable = true;   
        Serial.println("available");
    }
    delay(1000);
}
//receive notice from "home base" argon to light the parking lot LED
void timeLimit(const char *event, const char *data){
   
    if (parkingAvailable == false){
        digitalWrite(timerLED, HIGH);
    }
    else if (parkingAvailable == true){
        digitalWrite(timerLED, LOW);
    }
    else {
        digitalWrite(timerLED, LOW);
    }
    
}

"Home base" code

C/C++
int led1 = D7; 
bool complete;

void setup() {
 pinMode(led1, OUTPUT);
 Particle.subscribe("unavailable", ledOn);
 Particle.subscribe("available", ledOff);
}

void loop() {

}
//if the first argon senses a car parked in the lot, it will send a signal to the "home base" to notify them that a car is parked there. Once they receive the signal, it will send another signal back to notify the driver to pay their parking lot fare.
void ledOn(const char *event, const char *data) {
    digitalWrite(led1, HIGH);
    complete = true;
    Particle.publish("parkingJob", String(complete));
}
void ledOff(const char *event, const char *data) {
    digitalWrite(led1, LOW);
    complete = true;
    Particle.publish("parkingJob", String(complete));
}

Credits

Kristen Binkley

Kristen Binkley

0 projects • 0 followers
Greta Powell

Greta Powell

0 projects • 1 follower

Comments

Add projectSign up / Login