Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
cbou12oo
Published © GPL3+

Ultrasonic parking radar

This project aims to build a powerful ultrasonic parking radar that may be used in your very expensive car... or not!

IntermediateFull instructions provided330
Ultrasonic parking radar

Things used in this project

Story

Read more

Schematics

wiring

Schema

Code

codes

C/C++
#include <HCSR04.h>
int BRUIT = 2;
const int VERT = 13;
const int JAUNE =12;
const int ROUGE = 11;
double dist;
HCSR04 hc(5, 6);

void setup() {
   pinMode(BRUIT,OUTPUT);
   pinMode(VERT, OUTPUT); 
   pinMode(VERT, OUTPUT); 
   pinMode(JAUNE, OUTPUT); 
   Serial.begin(9600);  
}

void loop() {
   dist = hc.dist();
   Serial.println(dist);
   if (dist>30|| dist == 0){
     digitalWrite(VERT, HIGH);
     digitalWrite(JAUNE, LOW);
     digitalWrite(ROUGE, LOW);
     digitalWrite(BRUIT, LOW);
   }
   else if (dist>20 && dist<=30){
     digitalWrite(VERT, LOW);
     digitalWrite(JAUNE, HIGH);
     digitalWrite(ROUGE, LOW);
     digitalWrite(BRUIT, HIGH);
   delay(50);
   digitalWrite(BRUIT, LOW);
   }
    else if (dist<=20 && dist>0){
     digitalWrite(VERT, LOW);
     digitalWrite(JAUNE, LOW);
     digitalWrite(ROUGE, HIGH); 
     digitalWrite(BRUIT, HIGH);
    }
   delay(1000);
}

Credits

cbou12oo
0 projects • 0 followers

Comments