Re: Writing Code that Multitasks

i've learnt some of the basic coding of how to control the motor(hacked servo) ; speed and direction control. but i've yet to learn a combination of digital ir sensor coding and the change of direction when its detect an obstacles.

most of the coding i've see is not using digital ir sensor. if anyone could help, i'll appreciate your help. im just a noobies in this community (my first post tho).

if any of you can give a link to my problem, that will be okay. thank you.

i’ve learnt some of the basic coding of how to control the motor(hacked servo) ; speed and direction control.
but i’ve yet to learn a combination of digital ir sensor coding and the change of direction when its detect an obstacles.

Can you read the value returned by the IR sensor(s) ?
Do you know how to write code that does something if a condition is met ?
You know how to control the direction and speed of the motor(s)
So, if the IR sensor returns value (something) turn right
if the IR sensor returns value (something else) turn left
else keep going straight.

Which part are you stuck on ?

Robozon's going to be confused... this thread was actually an OT post on another thread and I asked the mods to split it off, which they obviously did.

That explains the Re: in the title, although this is a new thread and has nothing to do with multitasking.

The best tip is to learn about state machines. Sensors are sensors and actuators are acutators but a state machine is the simplest and most effective and least error prona way to get them to work together. Once you got that right and know how to design a state diagram for any given problem it is a small step to run concurrent state machines

@JimboZA, thanks for the clarification - I had seen the donor Thread so was confused.

@robozon, it would help if you modify your original post in this Thread and edit the Title to something more appropriate.

…R

robozon: most of the coding i've see is not using digital ir sensor. if anyone could help, i'll appreciate your help. im just a noobies in this community (my first post tho).

if any of you can give a link to my problem, that will be okay.

For interfacing Arduino with IR remote capabilities (sending or receiving) there is the "IR remote library": https://github.com/shirriff/Arduino-IRremote