Go Down

Topic: Programming logic using 2 ultrasonic sensor hc-sr04 (Read 3390 times) previous topic - next topic


Im, sorry how to print raw result?
i only know how to use serial.print.


i only know how to use serial.print.

So, use that to print the values returned by the rangefinders, before you make any decisions based on those values.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


instead of "out of range" post the reading .... ie what's the value..

Code: [Select]

 if (distance >= 3 && distance <= 50)
   Serial.println(" cm");
   digitalWrite(LED, HIGH);
  if (bdistance >= 3 && bdistance <= 50)

   digitalWrite(LED2, HIGH);
 else {
    Serial.println("Out of range");
    Serial.println(" cm");

    digitalWrite(LED, LOW);
    digitalWrite(LED2, LOW);


i use "else if" right now and i use the delay. it seems to work fine..
thank you for all your help guys..  :D


Could you list your current code that works?
I just purchased one of these sensors on ebay and need some help figuring out the code for it. I thought this module would be the same as the Ping))). I was wrong, but hope to get it to work just as well.

Thank you.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131