multitasking??

I'm new to the Arduino, please forgive me if my question is simple. Used to do a lot of work withthe Basic Stamp but I like the Arduino much better.

Is there a way to 'multitask' with the Arduino in terms of servo control.... ie, can I send servo commands via the servo library while executing other code, say sensor input? My problem is waiting for the servo commands to finish, which holds up my other sensor code.

Thanks for the help!

The distributed Arduino servo library or the MegaServo library do not need to wait once a value has been written

information on the servo library is here: http://www.arduino.cc/en/Reference/Servo

You can find MegaServo here: http://www.arduino.cc/playground/Code/MegaServo

The Arduino has several features, like A/D conversion, serial send/receive, and some servo/PWM control, that are done with hardware instead of software (like many Stamp functions are). So many things that would tie up the CPU on a Stamp can be done "in the background" on an Arduino without any sort of software multitasking.

Ran

Just to be clear, A/D conversion (analogRead) and Serial.print are not currently done in the background, they do block until the function is completed.

You don’t have to use analogRead() if you want to do overlap, though.

I was thinking more about the fact that serial I/O is bit-banged on the Stamp (at least, it is on the older ones that I used to play with), but I appreciate the correction about Serial.print: I didn’t know that there’s no transmit buffer. Now that the ATMega328 is becoming more common, it seems like it would be worth doing a variant of the serial driver with interrupt-driven send.

Ran

it seems like it would be worth doing a variant of the serial driver with interrupt-driven send.

there is some discussion in the developers forum about implimenting that.

Adding true multitasking to the Arduino platform is quite a bit of work because it affects so many other libraries.

In the meantime this discussion on Finite State Machines and a simple task library might be of help.