Using co-routine in an Arduino

Hey everybody, I'd like to know how I could use co-routine in an arduino. For example, I have a motor that's always spinning, it never stops, and I have a servo, that every 10 seconds it rotates, without stoping the other motor.

I know c# that's why I said co-routine.

Thanks

You have to spin your motor so that it never stops without trapping your code in the motor spinning routine. And learn to move your servo every ten seconds without using the delay function. Perhaps if we could see some of this code we could offer some more concrete suggestions.

You don't necessarily need coroutines to do that. Assuming a DC motor, you just set the PWM value for it's speed and use 'millis()'-based timing to update the servo position every 10 seconds. (As Delta_G just said as I was typing. :) )

Check out this thread:- Demonstration code for several things at the same time

And also look at "BlinkWithoutDelay" in the IDE examples.

Ohh thanks a lot guys, it worked, I used the Millis function to do it. Thanks again

Lukx31tuto:
Ohh thanks a lot guys, it worked, I used the Millis function to do it.
Thanks again

That was too easy. :slight_smile: