Multitasking with Arduino | Relay Timer Controller

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
thus our arduino microcontroller is capable of doing two or more tasks at the same time the answer is no because arduino microcontroller is a single core microcontroller and it is processing every task in sequential manner but we can virtually achieve multitasking by taking the advantage of the microcontroller's speed it basically switches from one task to the other task in fast phase to make it aware that many tasks are happening at the same time if you really want to achieve let's say to turn on two different led at exact same time i would suggest to use field programmable gate array or fpga where the processing is done in consecutive manner to achieve multitasking with arduino you can choose from the following option by using timer interrupts or by using millis function which basically use the timer 0 interrupt or by using state machines and lastly by using real-time operating system or rtos in my opinion state machines rtos and millis are all derived from timer interrupts in this demonstration we will focus with the use of millis function because this is the easiest to understand even the arduino provided an example in using millis the blink without delay example in here i prepare demo circuit which is consists of the following three button switches three leds that simulates relay on and up state a 16 by two lcd for the display of the menu and an arduino uno board as the main microcontroller the menu is needed so we can set specific duration of the on state of the relay and the millis function is used to achieve multiple tasks at almost the same time like navigating the lcd menu using the buttons and at the same time controlling the duration of downstate of the relay so let's demonstrate it the links of the circuit diagram in the arduino sketch will be provided in the description please feel free to modify it and adapt to your specific applications these buttons the first buttons in the left should be for the left direction this is for the center is for the enter and uh last in the right is for right button as you can see it's written here e por menu so let's press the e we can navigate the menu by using the buttons we can hide the menu and it will go back to main screen so let's go in inside again with the menu let's select the relay red which is this one for the first relay as of now the duration is zero so to modify that one we go right and edit the value so inside the sub menu we have the duration which displays the current set time next is edit to edit the duration next is execute to execute the uh on state of the relay and back so to return to the main menu so let's go in let's edit the duration let's say this one is two seconds and let's execute so the led will turn on for two seconds then it will turn it off back again so let's execute again executing red and it will turn up so let's uh let's go back let's say we choose the relay and edit the value let's say this one is for 30 seconds maybe save execute then let's go back and let's edit the duration of the relay blue let's say 7 and execute so as you can see we are able to multitask using the millis function so that's it if you like this video please give me thumbs up and share this to your friends if you have question or suggestion please do write it in the comment box please do not forget to subscribe and click the notification bell so you will be notified the moment i uploaded a new video thank you and have a good day bye you
Info
Channel: TechToTinker
Views: 13,328
Rating: undefined out of 5
Keywords: multitasking in Arduino, Arduino multitasking, millis, relay timer controller, multithreading arduino, Arduino multithreading, protothreading, lcd menu
Id: ylLiFOdPCWQ
Channel Id: undefined
Length: 6min 55sec (415 seconds)
Published: Wed Jul 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.