Hi there. I'm pretty new to this, and I was wondering if someone could find my error in here. I just want it to beep when an object is placed in front of it. I can seem to find my error. I'm using the active buzzer piece and ultrasonic sensor. Thank you in advance.
sensor_basics.ino (1021 Bytes)
Trying using a float for distance and using:
distance = (float)duration * 0.034 / 2.0;
There is nothing obviously wrong with the program, except that it won't compile due to a missing "}" in the loop function.
State what values are printed out for "distance".
Describe the buzzer type (post a link to the product page) and your wiring. Many buzzers are not activated by a simple HIGH on a digital pin, but require use of the tone() function to produce continuous sound.
Blackfin:
Trying using a float for distance and using:
distance = (float)duration * 0.034 / 2.0;
Do NOT use float if you don't have to. Float arithmetics introduce strange rounding errors and consume a lot of memory and time!