Ok, I am trying to combine all the information I have been given. I tried to make things clearer. I am getting this error now:
'pingRange' was not declared in this scope
Here is a current copy of the program. Thank you all for the help. I have a few h bridges I could use but I don't feel I would learn as much that way. Besides I saving them for a build up of this project once I grasp a better understanding of what I'm doing.
#include <Servo.h>
Servo myservoA;
const int pingPin = 7;
void robotRight()
{
if (microsecondsToInches(pingRange(pingPin)) < 10)
myservoA.write(90);
delay(1000);
}
else
{
myservoA.write(0);
}
}
void setup()
{
myservoA.attach(4);
delay(5000);
myservoA.write(0);
Serial.begin(9600);
}
void loop()
{
unsigned long pingRange (byte pingPin)
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
return pulseIn(pingPin, HIGH);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
[code/]