#include <LiquidCrystal.h>
#include <Adafruit_NeoPixel.h>
#define numLeds 1
#define pinNumber 6
#define TRIGGER_1 8
#define ECHO_1 7
Adafruit_NeoPixel pixels = Adafruit_NeoPixel (numLeds, pinNumber, NEO_GRB + NEO_KHZ800);
LiquidCrystal lcd(12, A5, A4, A3, A2, A1);
//Ultrasonic sensor_L(10, 9);
//Ultrasonic sensor_R(8, 7);
unsigned long temp = 0;
float distancia = 0;
void setup() {
pinMode(ECHO_1, INPUT); //Pino ECHO de saída
pinMode(TRIGGER_1, OUTPUT); //Pino TRIGGER de entrada
pixels.begin();
lcd.begin(16, 2);
lcd.clear();
}
void loop() {
digitalWrite(TRIGGER_1, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER_1, LOW);
temp = pulseIn(ECHO_1, HIGH, 20588);
distancia = temp/58.0;
if(distancia<10.0){
lcd.print("VAGA - LIVRE");
pixels.setPixelColor(0,pixels.Color(0, 255, 0));
}
else{
lcd.print("VAGA - OCUPADA");
pixels.setPixelColor(0,pixels.Color(255, 0, 0));
}
delay(500);
lcd.clear();
pixels.show();
}
Comments