Blake ParkerNick MendlikClay Brockmann
Published

Particle Argon Parking Assistant

Older vehicles do not possess the same features of the vehicles of today. This simple device aims to remedy that problem with park assist.

BeginnerShowcase (no instructions)59
Particle Argon Parking Assistant

Things used in this project

Hardware components

Argon
Particle Argon
×3
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
Breadboard (generic)
Breadboard (generic)
×3
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×10
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

LED and Sensor Schematic

These diagrams show the circuits for both types of modules used. This wiring is all that is necessary to send, receive, and display signals from a sensor.

Code

LED Code

C/C++
int led = D7;

void setup() {
    
Particle.subscribe("Front_IOTParkSensor", Frontcbn_IOT_ParkSesnor_Handler, MY_DEVICES);
Particle.subscribe("Back_IOTParkSensor", Backcbn_IOT_ParkSesnor_Handler, MY_DEVICES);
// subscribe to the HC-SR04 sensor. Name is MEGR3171_IOTGROUP18_ParkingSensor 
// The handler name is used below for the void loop. Make sure name is identical. 

Serial.begin(9600);

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

}

void loop() {

}

void Frontcbn_IOT_ParkSesnor_Handler(const char *event, const char *data){
    
   digitalWrite(led,HIGH);
   
    if (strcmp(data,"Clear")==0) {
        
        // if the car is far away, then turn your board LED and buzzer off
       digitalWrite(led,LOW);
    }
    else if (strcmp(data,"STOP")==0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led,HIGH);
       
    }

    delay(1000);
}

void Backcbn_IOT_ParkSesnor_Handler(const char *event, const char *data){
    
   digitalWrite(led,HIGH);
   
    if (strcmp(data,"Clear")==0) {
        
        // if the car is far away, then turn your board LED and buzzer off
       digitalWrite(led,LOW);
    }
    else if (strcmp(data,"STOP")==0) {
        // if the car is under 60 cm away, turn your board LED and buzzer on
        digitalWrite(led,HIGH);
       
    }

    delay(1000);
}

Sensor Code

C/C++
// defines pins numbers
#define trigPin	D2
#define echoPin	D6
// defines variables
long duration;
long distance;
void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  Serial.begin(9600); // Starts the serial communication
}
void loop() {
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);
  
 if(distance<=80){
       Particle.publish("Front_IOTParkSensor","STOP",PRIVATE);
    }
    else{
      Particle.publish("Front_IOTParkSensor","Clear",PRIVATE);
      }
    delay(1000);
   }

Credits

Blake Parker

Blake Parker

0 projects • 0 followers
Nick Mendlik

Nick Mendlik

0 projects • 0 followers
Clay Brockmann

Clay Brockmann

0 projects • 0 followers
Thanks to Christa Loucks.

Comments

Add projectSign up / Login