Am I able to start some sort of Sequence?

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);
}

My exact question is;

“Can I add a line underneath the else statement which starts another sequence which can only be stopped by completing the sequence?”

It would be most ideal if I could write the sequence without it being directly in there. Like I would give a piece of script a name, which can be started in a way simular to.

else {
Start “TurnRight”;
}

“Can I add a line underneath the else statement which starts another sequence which can only be stopped by completing the sequence?”

Yes, for some definition of “sequence”. If you mean function, then yes, you can do that.

It would be most ideal if I could write the sequence without it being directly in there.

That’s what functions are for.

Do you know where I can find a tutorial on that?

Did you try Google?

No, what's google?

BenHeistee:
No, what's google?

What planet did you say you were from?

Hahaha, I'm from planet Earth!

Google hasn't provided me with a clear explanation. I could copy paste everything, but I would like to be able to understand what I'm writing.

Google hasn't provided me with a clear explanation.

So, you know what google is, and were just being a dick.

I'd wish you luck on your project, but, frankly, I no longer care.

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