RC car control Help

Hello,

THE OBJECTIVE: for my project, i'd like to install a sonar sensor in front of the car. once an object (obstacle or wall) detected, then the car stops.

THE APPROACH: NOTE: i can't post the link on my first post, so you can search PING in adruino website, for better visual.

using the ADRUINO UNO and Ping Ultrasonic Range Finder.

I was thinking, getting an output from the UNO. Then use that output to open a switch (relay). This switch will deactivate the car motor.

THE QUESTION(S): how can i achieve that? can i get an electrical signal as an output?

PLEASE HELP,

Bassam

THE OBJECTIVE: for my project, i'd like to install a sonar sensor in front of the car. once an object (obstacle or wall) detected, then the car stops.

If that is your only objective you can probably do it with much simpler and cheaper solutions. The simplest way, although not as elegant, is to just just a touch switch attached to your front (or rear) bumper. Whenever the car hits an object, the switch will engage and you can use any digital ports to read that information out.

The PING sensor (more generically the ultrasound range sensor) can be used for more sophisticated tasks such as distance measurement, etc...

I'm required to use a sonar sensor. plus, with the car speed a touch switch can cause damages.

I was thinking to assign a minimum distance between the car and any other object, then

IF DISTANCE = MINIMUM; THEN send some type of output the turn the motor off;

is this possible?

Yes, you can easily do what you want to do.

This code is what I am using for my wifitank, to measure the distance to things in front and behind it, so it won't drive into things.

double ping(int outPin, int inPin) //Get CM to obstacle in front of the sensor
{
  long duration;
  pinMode(outPin, OUTPUT);
  pinMode(inPin, INPUT);
  digitalWrite(outPin, LOW);
  delayMicroseconds(2);
  digitalWrite(outPin, HIGH);
  delayMicroseconds(15);
  digitalWrite(outPin, LOW);
  delayMicroseconds(20);
  duration = pulseIn(inPin, HIGH, 10000); //10000 timeout to make sure the loop wont slow down too much
  return duration / 29.0 / 2.0;
}

thnx for replying, but I should've mentioned that you can consider me as a biggner.

Can you provide more comments for the codes?

thnx

thnx for replying, but I should've mentioned that you can consider me as a biggner.

Can you provide more comments for the codes?

thnx

I would like that too.

Thanks,

THere is a well commented code on the website ! :) http://www.arduino.cc/en/Tutorial/Ping

I should have known.

Thanks!