Kyah BakerDean Vrettos
Published © GPL3+

Parking Notifier IOT Project

Green Light... Red Light!

BeginnerFull instructions provided2 hours577
Parking Notifier IOT Project

Things used in this project

Hardware components

Argon
Particle Argon
×2
Amazon Web Services RGB Programmable pixel led strip
×1
SparkFun Ultrasonic Distance Sensor - HC - SR04
×1
USB Cable, USB Type C Plug
USB Cable, USB Type C Plug
×2
Resistor 220 ohm
Resistor 220 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×9
KY-006 PASSIVE PIEZO-BUZZER MODULE
×1

Software apps and online services

Maker service
IFTTT Maker service
Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets

Story

Read more

Schematics

Circuit Setup for HC-SR04

Shows the connection of the particle argon with the HC-SR04 sensor

Buzzer on Circuit Example

not a particle argon but the same concept applies

Ultrasonic Sensor Circuit

This is the setup for the ultrasonic sensor connected to the argon.

Hardware:
SparkFun Ultrasonic Distance Sensor
Jumper cables
Argon
Breadboard
USB cable

RGB Circuit

This is the setup for the LED strip connected to the argon and buzzer

Hardware:
SparkFun buzzer
RGB Programmable Pixel LED Strip
Jumper cables
Breadboard
Argon
USB cable

Code

Ultrasonic Sensor on the breadboard circuit

C/C++
This is the code for the ultrasonic sensor on the breadboard circuit
// Pin Definitions 

#define HCSR04_PIN_TRIG	D2                  // Important
#define HCSR04_PIN_ECHO	D6                  // Also Important 

int sound = 0; 



void setup() {
    
  // setup code here! 
  Serial.begin(9600);
 
  pinMode(HCSR04_PIN_TRIG, OUTPUT);
  pinMode(HCSR04_PIN_ECHO, INPUT);


   
}


void loop() {
  // main code here, runs in a loop 
  
  long timeTaken, distance;                      // HC-S04 code starts here, can be found in the cold dark depths of HC-S04 docs
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(HCSR04_PIN_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(HCSR04_PIN_TRIG, LOW);
  timeTaken = pulseIn(HCSR04_PIN_ECHO, HIGH);     //determine distance of wave
  distance = (timeTaken/2) / 74;                  //using timeTaken calc distance of object

  /*determine corressponding leds to light up with respect to the distance
  of object*/
 
 if(distance<20){
     Particle.publish("Car_Arrived5", "On", PRIVATE);             // this is what your delcaring to hapen when the distance is under X amount of inches
      delay(1500);                                                // every 1.5 seconds it refreshes for faster response time to detect car
 }
    
   else{
      Particle.publish("No_Car2", "Off", PRIVATE);                // when the distance is above X amount, it declares something else
 }
   delay(3500);                                                   // every 3.5 seconds it refreshes for faster response when no car is detected
   }
  
        
        
        

RGB light Strip Code

C/C++
code for the LED light strip and also the buzzer
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>    // Can be found on libraries 


int buzzer = D3;         // Buzzer is connect to the D3 on the particle argon 
int state = 0;            
int sound = 0;          

#define PIXEL_PIN D7           // the RGB strip is connected to the D7 on the light strip breadboard
#define PIXEL_COUNT 15        // How many led lights are on the strip
#define PIXEL_TYPE WS2812B   // pretty good brand of lights

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); // important 

//Defines the color all pattern(makes whole strip one color)
void colorALL(uint32_t c, uint8_t wait) {
  uint16_t i;

  for(i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
  }
  strip.show();
  delay(wait);
}




void setup() {
    
    
  
 
Particle.subscribe("hook-response/Car_Arrived", Sensor, "e00fce68b13fbc0a0eeda9b6");   // recevies the data from the argon connected to the HC-S04
strip.begin();
strip.show();


Serial.begin(9600);               

colorALL(PIXEL_PIN,OUTPUT);      // LED strip is an output 

pinMode(buzzer,OUTPUT);       // buzzer is an output 
digitalWrite(buzzer,LOW);    // buzzer needs information 
}


void loop () {

}
      
void Sensor(const char *event, const char *data) // important 
{
   
   digitalWrite(buzzer,HIGH);
 
   if (data="On") {                                       // when data received is "ON" begins the code underneith
     colorALL(strip.Color(100, 0, 0), 5);                // The LED strip glows Red
       digitalWrite(buzzer,HIGH);                       // buzzer makes noise
   delay(15000);
    
    } else if (data="On") {                              // this "else if" doesnt matter unless ur trying to add yellow inbetween your red and green. 
     colorALL(strip.Color(255, 255, 0), 5);
       digitalWrite(buzzer,HIGH);
   delay(15000);
  
    
   } 
   else if (data="OFF"); {                               // when data received is "OFF" begins the code underneith 
        colorALL(strip.Color(0, 100, 0), 10);           // The LED strip glows green
        digitalWrite(buzzer,LOW);                      // buzzer will not make noise
        delay(1000);
        
}
     
}

        /

Credits

Kyah Baker

Kyah Baker

1 project • 1 follower
Dean Vrettos

Dean Vrettos

0 projects • 2 followers
Here to have fun
Thanks to Nathaniel Shephard .

Comments