I am creating a parking assistant application. When I attempt to run the application with my code, no distance values are displayed.
My arduino code is here:
const int trigPin = A2;
const int echoPin = A3;
long duration, cm;
void setup() {
// initialize serial communication with HC-06:
Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
cm = (duration/2)/29.1;
float val2 = digitalRead(cm);
Serial.println(val2);
delay(400);
}
The MIT Application code can be seen here
If anyone knows how to fix my issue, please let me know! Thank you!