I am new at using an arduino, and posting for help, so please be easy on me.
I purchased a HRLV Max Sonar- EZ with the goal of creating a water height measurement tool.
Anyways, I am using this code:
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
pinMode(10,OUTPUT);
pinMode(13,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
float duration, distance;
digitalWrite(10, LOW);
delayMicroseconds(10);
digitalWrite(10, HIGH);
delayMicroseconds(10);
digitalWrite(10, LOW);
if (distance >= 400 || distance <= 2){
Serial.print("Distance = ");
Serial.println("Out of range");
}
else {
Serial.print("Distance = ");
Serial.print(distance);
Serial.println(" cm");
delay(500);
}
delay(500);
}
I believe it is working fine, but my Serial Monitor reads, "Out of range". I have tried increasing the amount of Microseconds in the delay, in case it wasn't receiving a signal fast enough, but this didn't work.
I am very new to this, so I have attached a photo of the set up I have in case this is flawed.
I'm an ecologist, just trying to make a cheap advice to monitor stream height.
Any help is appreciated!