Maker Pro
Maker Pro

Multitasking with Arduino

etka besim

Mar 28, 2017
2
Joined
Mar 28, 2017
Messages
2
i wanna control Speaker and Servo motor together with arduino . How can i control these together ? i hope you help me :)
 

kellys_eye

Jun 25, 2010
6,514
Joined
Jun 25, 2010
Messages
6,514
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.
 

Mike_Lemon123

Jul 7, 2017
7
Joined
Jul 7, 2017
Messages
7
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
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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)
 

Mike_Lemon123

Jul 7, 2017
7
Joined
Jul 7, 2017
Messages
7
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.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Are you bit banging your pwm?
 

sumeryamaner

May 29, 2017
50
Joined
May 29, 2017
Messages
50
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