#include <LiquidCrystal.h>
const int FROS = A1;
const int FLOS = A2;
const int RROS = A3;
const int RLOS = A4;
int FR = 0;
int FL = 0;
int RR = 0;
int RL = 0;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
pinMode(FROS, INPUT);
pinMode(FLOS, INPUT);
pinMode(RROS, INPUT);
pinMode(RLOS, INPUT);
Serial.begin(9600);
}
void loop()
{
FR = analogRead(FROS);
Serial.println(FR);
FL = analogRead(FLOS);
RR = analogRead(RROS);
RL = analogRead(RLOS);
lcd.setCursor(1, 0);
lcd.print("FR FL RR RL");
if (FR <= 500 && FL <= 500 && RR <= 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("No Obstacle ");
}
else if (FR > 500 && FL <= 500 && RR <= 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("XX ");
}
else if (FR <= 500 && FL <= 500 && RR <= 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX");
}
else if (FR <= 500 && FL <= 500 && RR > 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX ");
}
else if (FR <= 500 && FL <= 500 && RR > 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX XX");
}
else if (FR <= 500 && FL > 500 && RR <= 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX ");
}
else if (FR <= 500 && FL > 500 && RR <= 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX XX");
}
else if (FR <= 500 && FL > 500 && RR > 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX XX ");
}
else if (FR <= 500 && FL > 500 && RR > 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print(" XX XX XX");
}
else if (FR > 500 && FL <= 500 && RR <= 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("XX ");
}
else if (FR > 500 && FL <= 500 && RR <= 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX");
}
else if (FR > 500 && FL <= 500 && RR > 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX ");
}
else if (FR > 500 && FL <= 500 && RR > 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX XX");
}
else if (FR > 500 && FL > 500 && RR <= 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX ");
}
else if (FR > 500 && FL > 500 && RR <= 500 && RL > 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX XX");
}
else if (FR > 500 && FL > 500 && RR > 500 && RL <= 500)
{
lcd.setCursor(1, 1);
lcd.print("XX XX XX ");
}
else
{
lcd.setCursor(1, 1);
lcd.print("Call Help ...... ");
}
}
Comments