Notes
January 15, 2016, 10:23am
1
Hi
For my project (indoor navigation with ultrasonic) I have bought two ultrasonic sensors: http://www.ekulit.com/ultrasonic-sensor/16ptr10/
My question is how can I measure if the sensor receives a sound?
This is my code which I tried:
int analogPin = A4;
void setup() {
Serial.begin(115200);
pinMode(analogPin, OUTPUT);
digitalWrite(analogPin, HIGH);
}
void loop() {
float value;
value = analogRead(analogPin);
String sf(value, 5);
Serial.println(value);
delay(10);
}
I can't use HC-SR04 ultrasonic module because I need the distance between two ultrasonic sensors and not between one sensor and the nearest obstacle.
Do I need anything else to make this work? Where is my mistake?
I think you need something else to make this work. Show us your schematic.
Notes
January 15, 2016, 5:30pm
3
Thanks for your answer. Here is my simple schematic:
If I run the program using the code from above I get this output.
4.00
4.00
3.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
4.00
3.00
4.00
4.00
4.00
4.00
4.00
3.00
4.00
3.00
3.00
4.00
3.00
3.00
4.00
4.00
According to the docs analogRead() returns 0 to 1023.
You are missing quite a lot to make this work. You need to DRIVE the ultrasonic transducers.
Notes
January 16, 2016, 9:37am
5
Paulcet:
You need to DRIVE the ultrasonic transducers.
Can you show me an example please? Something like what i need.
Thank you in advance
system
January 18, 2016, 3:20pm
7
If I read your original post correctly, what you've got there is a bit like having just a piston.
Sure, it's an essential part of an internal combustion engine, but it's not going to do anything useful without more components.
You need to be able to drive it with quite high voltages (check the data sheet) to make it shout as loud as it can, and at the correct frequency, and you need a fair amount of amplification to make out the potentially very weak signal when it receives an echo.
See if you can modify the Ping example to use one unit for the trigger and one for the echo.
Examples -> 06.Sensors -> Ping
system
January 18, 2016, 5:44pm
9
Jobi-Wan:
See if you can modify the Ping example to use one unit for the trigger and one for the echo.
Examples -> 06.Sensors -> Ping
The ping example assumes you've got a ready-built sensor, with drivers for the transmitter and an amplifier for the receiver.