ultrsound arduino

I found this scheme on the net, and decided to try out because he had all the components ..

On the site over the code used is for a pic, and I was trying to convert to arduino, but I do not know how to write in arduino.

I searched on the net, code samples, not only able to do anything until now.

If someone can give a help thank you.

Looks a lot like a PING))) sensor, so the code for that should work.

This is a bare setup. The ping ))) sensor has on-board electronics that sends out ultrasonic pulses and senses the reflected pulses and produces a single pulse as a reply to a microcontroller, proportional to distance. This thing needs you to monitor all pulses that reflect back and possibly amplify the reflected signal to detect them.

Here is one that uses a pair of transducers:
http://emartee.com/product/41911/Arduino%20Ultrasonic%20Range%20Detection%20Sensor

(with some sample code)

You can pick up these ping modules for $3-6 on ebay.

--- bill

I've been doing some testing, the example of code that said user token always 0 in 0 cm, to try out the analog port and plug always 322.

const int pingPin = 7;
const int pingPin0 = 0;
void setup() {
Serial.begin(9600);
}

void loop()
{

pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);

pinMode(pingPin0, INPUT);
duration = digitalRead(pingPin0);

Serial.print(duration);
Serial.println();

delay(100);
}

You might want to consider changing pingPin0 to another pin. Digital pin 0 is the rx pin for the main serial port (USB serial connection).

Good afternoon,

I auditioned with the doors 4 and 5 of arduino and get the same problem

In any case, don't use pin 0. That is the rx pin for your Serial.xxx() stuff.

The sample code at the site you posted the link recommends a 300us pulse to acquire a signal. A 2us or 5us pulse is not nearly long enough to acquire a signal on a 40khz audio pulse (25us per cycle). That would not even be one cycle. You will probably need 5-10 cycles to acquire.

Take a look at the ping tutorial example as PaulS suggested: http://www.arduino.cc/en/Tutorial/Ping.

Note that it's using pulseIn to read the duration - your use of digitalRead instead is part of your problem

Good afternoon,
From what I understand of all the tutorials I saw on google, it always used the circuit board, and links to the arduino only one wire.

In the scheme of post that I have a 2 wire is connected to the Arduino and 1 pwm 2 to pulse.

I think the problem ping the tutorial is missing part of the PWM, or is not it.

liudr:
This is a bare setup. The ping ))) sensor has on-board electronics that sends out ultrasonic pulses and senses the reflected pulses and produces a single pulse as a reply to a microcontroller, proportional to distance. This thing needs you to monitor all pulses that reflect back and possibly amplify the reflected signal to detect them.

OP,

As I said a million years ago on the above reply, your code will NEVER work. The code is for Parallax ping ))) sensor and what you made out of parts is not ping ))) sensor. I don't have code for your basic setup but if you really want to save money, why not getting this ping-compatible sensor for cheap to save yourself from the trouble?

http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&item=270755218294

See how cheap it is? I just bought 4 and they're on their way to me.

BTW, your homemade sensor will have a poor range even if you use the right code for it. It has no amplifiers!