Hi, I'm newbie at programing so I have a question. can I write a different programs (in a single sketch) for a robot like move forward, move back, turn left and turn right and then just name it some how and just call it then I need it?
can I write a different programs (in a single sketch) for a robot like move forward, move back, turn left and turn right and then just name it some how and just call it then I need it?
Different programs? No. Functions? Yes. You not only can, you should.
yes functions was what i mean, so maybe u can show some examples or something like that, cause those one that I found in arduino site isnt very good :)
void TurnLeft () {
// code that turns the bot left
}
void TurnRight () {
// code that turns the bot right
}
void MoveBack () {
// code that moves the bot backwards
}
void loop () {
TurnLeft();
MoveBack();
TurnRight();
}
I suggest you find a "Programming in C" book or online reference and have a good read.
Also check out examples of other people's code.
Rob
Thanks now I get it