Maker Pro
Maker Pro

Multitasking with Arduino

The Arduino has multiple 'ports' that can be used to drive many different accessories simultaneously.

Check out any reputable Arduino seller and look for speaker and servo modules that can be purchased to connect to the Arduino.

It's then a case of either writing your own software or downloading one of the many 'sketches' that can be incorporated into your design.
 
I don't know if it's the standard way but this is a way I developed multitasking.

never use the function delay(); and if you need timing function for accelerations and stuff like that just use timers (I Use "long" variable for that) along with the function millis() and if statements to check if at the current interval you have reached that time. also I use some flags for some processes and store them in variables.

Just say if you wanna learn about it more in depth but arduino has a good example about basic multi tasking using the example "delay without blink" of course it's not as accurate as using the delay function but it is essential sometimes and this processor is so fast you can't tell the difference.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
If you implement your functions using state machines and no delays, you can call one state machines and then the next (alternating) and you will have a useful form of multitasking.

Also be aware that the atmega chip has peripherals which can be set running and left (the PWM outputs are a good example)
 
If you implement your functions using state machines and no delays, you can call one state machines and then the next (alternating) and you will have a useful form of multitasking.

Also be aware that the atmega chip has peripherals which can be set running and left (the PWM outputs are a good example)
yeah but this PWM is static while running other commands.
 
i wanna control Speaker and Servo motor together with arduino . How can i control these together ? i hope you help me :)

If you want to get help, you must provide details. What do you want to output to the speaker? A simple square wave sound or an mp3 file? What kind of servo motor are you talking about? A regular R/C servo or something else? What have you done until now and at which point do you have problems?
And finally, do you read the replies to your post?
 
Top