BenHeistee:
I'll try to make it as clear as possible,Were building an autonomous robot for school, we've got the code concerning the sensors under controle. But we've made it work with LED's instead of a program to drive the motors. I was wondering if there could be a way to make a statement which I could replace with the LED code to start a sequence in stead of lighting an LED.
what I have is this...
if ((distanceR <= 10) || (distanceRH <= 15)){
digitalWrite(ledR, HIGH);
}
else {
digitalWrite(ledR, LOW);
}
First convert that code so it uses two functions - perhaps like this
if ((distanceR <= 10) || (distanceRH <= 15)){
ledOn();
}
else {
ledOFF();
}
} // end of loop()
void ledON() {
digitalWrite(ledR, HIGH);
}
void ledOFF() {
digitalWrite(ledR, LOW);
}
Then you can replace (or supplement) the calls to ledON() and ledOFF() with calls to functions that cause your motor to move.
Have look at Planning and Implementing a Program
...R