Hello friends, with the data it receives from the distance sensor with the ardunio, if the distance is less than 5 cm, the red LED and the LCD screen are full of parking lot and if it is larger than 5 cm, the green led and LCD screen is empty, the ardunio code is simple. I want to connect it with MIT App inventor. What kind of code should I write for the program that says it is empty?
Ardunio Code
#define echoPin 13
#define trigPin 12
#define led 11
#define led1 11
void setup()
{
pinMode (trigPin, OUTPUT);
pinMode (echoPin, INPUT);
pinMode (led, OUTPUT);
pinMode (led1, OUTPUT);
}
void loop()
{
int olcum = mesafe();
if (olcum!= 0)
{
digitalWrite(led, LOW);
if (olcum <15)
{
digitalWrite(led, HIGH);
digitalWrite(led1, LOW);
}
else
{
digitalWrite(led1, HIGH);
digitalWrite(led, LOW);
}
}
}
int mesafe ()
{
long sure, uzaklik;
digitalWrite(trigPin, LOW);
delayMicroseconds (2);
digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite(trigPin, LOW);
sure = pulseIn (echoPin, HIGH);
uzaklik = sure / 58.2;
delay (50);
return uzaklik;
}