ARIEL NUNES BRAZ GOMESFernando F de Carvalho
Published

Sensor for parking spaces

A parking sensor made with Arduino !

BeginnerFull instructions provided1,586
Sensor for parking spaces

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×19
5 mm LED: Green
5 mm LED: Green
×2
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
Resistor 220 ohm
Resistor 220 ohm
I use this for the leds
×2
SparkFun Snappable Protoboard
SparkFun Snappable Protoboard
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Sensor for parking spaces Scheme

made on https://fritzing.org

Code

Sensor for parking spaces

Arduino
I use 3 librarys, 2 for LCD I2C display and 1 for ultrasonic sensor.
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

#include <Ultrasonic.h>

LiquidCrystal_I2C lcd(0x27,16,2);
Ultrasonic sensor_L(5, 4);
Ultrasonic sensor_R(6, 7);
int led_L = 9, led_R = 8;

void setup() {
  
  pinMode(led_L, OUTPUT);
  pinMode(led_R, OUTPUT);
  lcd.init(); 
  lcd.setBacklight(HIGH);
  lcd.clear(); 
}

void loop() {
  float cmMsec_L,cmMsec_R;
  long microsec_L = sensor_L.timing(), microsec_R = sensor_R.timing();
  cmMsec_L = sensor_L.convert(microsec_L, Ultrasonic::CM);
  cmMsec_R = sensor_R.convert(microsec_R, Ultrasonic::CM);
  
  if(cmMsec_L<10.0){
    lcd.setCursor(0,0);
    lcd.print("VAGA 1 - OCUPADA");
    digitalWrite(led_L, LOW);
  }
  else{
    lcd.setCursor(0,0);
    lcd.print("VAGA 1 - LIVRE");
    digitalWrite(led_L, HIGH);
  }

  if(cmMsec_R < 10.0){
    lcd.setCursor(0,1);
    lcd.print("VAGA 2 - OCUPADA");
    digitalWrite(led_R, LOW);
  }
  else{
    lcd.setCursor(0,1);
    lcd.print("VAGA 2 - LIVRE");
    digitalWrite(led_R, HIGH);
  }
  delay(500);
  lcd.clear();
}

Credits

ARIEL NUNES BRAZ GOMES
3 projects • 2 followers
Amante da tecnologia e louco por café. Sou um estudante com um brilho especial no olhar, aberto a diálogo e com sede de conhecimento.
Contact
Fernando F de Carvalho
20 projects • 8 followers
Contact
Thanks to Othon Gonzaga.

Comments

Please log in or sign up to comment.