I have here a lines of codes on my parking assistance project. I'm new to mitapp inventor and what i want to do is change the values of measured distance through the mitapp based on users preference. example the user want the measured value of the red is 17 inches. please help me!!!
void loop(){
long duration, Distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn (echoPin, HIGH);
Distance = (duration/2 ) /74; //distance in inches
if (counter < 20){ // Do the rest if the car is still moving
if (Distance > 200){ //nothing in garage
turnThemAllOff();
}
if ((Distance >40 ) && (Distance <= 200)){
digitalWrite(greenLed,HIGH);
digitalWrite(yellowLed,LOW);
digitalWrite(redLed, LOW);
noTone(buzzer);
}
if((Distance >15 ) &&( Distance <= 55)){
digitalWrite(yellowLed, HIGH);
digitalWrite(redLed, LOW);
digitalWrite(greenLed,LOW);
noTone(buzzer);
}
if (Distance <= 15){
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(yellowLed,LOW);
noTone(buzzer);
}
if (Distance <8) { // if object is too close - start buzzer
tone(buzzer, 500);
}
}
if ((Distance == TempDistance) || ((Distance+1) == TempDistance) || ((Distance-1) == TempDistance)){
if (counter >= 20){
Serial.println("No Movement detected, turning off the lights");
turnThemAllOff();
} else {
counter++;
}
} else {
counter = 0;
}
TempDistance = Distance;
Serial.print(Distance);
Serial.print("inches");
Serial.print("Counter");
Serial.println(counter);
delay(500);
displayStopDist();
display.display();
}