Тёмный

Arduino delay() and millis() Functions: Tight Loops and Blocking Code 

Programming Electronics Academy
Подписаться 234 тыс.
Просмотров 103 тыс.
50% 1

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@programmingelectronics
@programmingelectronics 4 года назад
****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB
@charmindesai3730
@charmindesai3730 3 года назад
Please make a video on how to use arduino timers
@michaelzajac5284
@michaelzajac5284 3 года назад
I was seriously considering about delay(2000) mean 2 seconds?
@yashaswikulshreshtha1588
@yashaswikulshreshtha1588 3 года назад
Lol I like how the lens was listening music and how you were pouring those components like something to be used for recipe LOL
@mrphysh
@mrphysh Год назад
good. My application is ... like a weather station: the Arduino is full of sensors, and I want to take data and put it into Python and then into a database. And I want a data sample every fifteen miinutes.
@billgaytes6845
@billgaytes6845 6 месяцев назад
In your example you have specified the buton pin = 5. However in void setup, you don't use [pin mode (button pin, input)], is that not necessary ?
@programmingelectronics
@programmingelectronics 6 месяцев назад
Great question! By default all the digital pins are set as inputs, so it's not necessary here. However, on my better days I usually explicitly set them as inputs using the pinMode function, as i feel like it is more clear, so i should have done that here as well.
@prvashisht
@prvashisht 2 года назад
I watched just for the music recipe and didn't get it :p
@Conorkc86
@Conorkc86 5 лет назад
Easy to spel. made me laugh :-)
@programmingelectronics
@programmingelectronics 5 лет назад
Thanks for watching!
@etiennegrix1738
@etiennegrix1738 5 лет назад
😉thank you for explaining the whole millis delay confusion from start to finish this will definitely help a lot of guys programming what they've always wanted. Can't wait for the next lesson!!!!
@quintonmcguinness6512
@quintonmcguinness6512 4 года назад
Please help. I am building a small alarm system. When sensor is triggered the siren must trigger and after 3 minutes switch of till the next trigger.
@ipadize
@ipadize 2 года назад
I am currently programming my arduino to move my camera to specific places and take pictures, a focus stacker. I am currently at over 1000 lines of code, is this a tight loop? :P
@programmingelectronics
@programmingelectronics 2 года назад
:)
@ivanivan4418
@ivanivan4418 3 года назад
This is very clear explanation for people like us. Please also make a video about interrupt. Those videos on utube are not as clear explanation
@nanditofernandeshornay8967
@nanditofernandeshornay8967 2 года назад
Sr. please make the code bellow becomes millis: Void loop () { if (digitaRead (tombol)==0){ digitalWrite (led, HIGH); delay (3000); digitalWrite (led, LOW); delay (3000); digitalWrite (led, HIGH); delay (3000); digitalWrite (led, HIGH); delay (3000); } else { digitalWrite (led, LOW); } } How to be version millis Sr..???.
@VasilisKarastergios
@VasilisKarastergios 5 лет назад
Looking forward for the millis(); series. Thanks for sharing your knowledge with us.
@philipanderson9434
@philipanderson9434 Год назад
Awesome explanations, I really enjoying this approach to teaching.
@programmingelectronics
@programmingelectronics Год назад
Thanks so much! Best of luck on your Arduino endeavors!
@chucklearnslithics3751
@chucklearnslithics3751 2 года назад
I'm curious about your take on branchless programming for tight Arduino loops.
@programmingelectronics
@programmingelectronics 2 года назад
Great question! I have not explored branchless programming much, so I don't really have a take on it quite yet.
@chucklearnslithics3751
@chucklearnslithics3751 2 года назад
@@programmingelectronics Yeah, I usually try to write my Arduino code as branchless as I can, but I have no idea if it makes a difference or not. I suspect it does. Some compilers are smart enough to take your conditional logic and optimize it into branchless logic, but I have doubted the native Arduino compiler has been built to do that. But I just don't know at the end of the day.
@mohamedessamhadid231
@mohamedessamhadid231 5 лет назад
Thank you very much, I hv always suffered a lot from this issue bt I couldn't find the correct way to phrase it in order to troubleshoot it 😂
@kresimirkekovladic8932
@kresimirkekovladic8932 3 года назад
and I ask you. are you normal ? You explain the difference between delay and millis and insert the for function. And how extensively you explain sorry but this video is Scary !!!!!
@spianny
@spianny 2 года назад
this is the greatest arduino content ive ever come accross!! Thank you soooo much and keep it up! please :)
@programmingelectronics
@programmingelectronics 2 года назад
Thanks so much for the comment!
@christopherlyons7613
@christopherlyons7613 Год назад
Not sure I agree with your definition of tight code. In general the specific length of time a loop spends is not really the main issue whether a loop is tight or not. A tight loop just has a non-blocking structure, so the time it takes to process is consistent with each run through the loop. When you introduce calls into a loop that will not provide consistent times to process than the tightness of your loop (and code) is compromised (think database calls, I/O reads, network processing calls, etc). I would say the example you give with the delay() function IS a tight loop (although generally not a goid programming practice due to the blocking). It will always stop your code for the set time so the loop time is consistent.
@donaldklopper
@donaldklopper 3 года назад
Yeah. Speling is easy ;-)
@josephanthony9294
@josephanthony9294 4 года назад
Excellent tutorial. Great explanations that clear up any misunderstandings ...and nice sense of humour. Thank you
@programmingelectronics
@programmingelectronics 4 года назад
Thanks Joseph!
@danhyatt2206
@danhyatt2206 11 месяцев назад
you spelled 'spell' wrong lol
@VidarrKerr
@VidarrKerr 6 месяцев назад
What is "Pay with checks"?
@gurilab
@gurilab 2 года назад
cheio de humor...kkkk...dah dah duh dah...
@programmingelectronics
@programmingelectronics 2 года назад
I'm trying :)
@jon_raymond
@jon_raymond 5 лет назад
Really great explanation! I might mention that delay() could also be explained as its own loop that has nothing in it other than counting the time given to it. This fits well with your explanation of the actual loop.
@ThuanDuong-pv3xu
@ThuanDuong-pv3xu 4 года назад
...So in smartphone We need multi cores, multi threads (hardware) multi functions (software) to play multimedia !!
@mkamranchaudhry680
@mkamranchaudhry680 3 года назад
Really very help full info and solid info
@programmingelectronics
@programmingelectronics 3 года назад
Glad it was helpful!
@elektro860
@elektro860 4 года назад
this is what i need
@DevoTecho
@DevoTecho 3 года назад
This was delay function.. not miles
@o-h-1
@o-h-1 5 лет назад
Bathroom Break😂
@vilmariojunior1
@vilmariojunior1 4 года назад
thank you for explaining
@programmingelectronics
@programmingelectronics 4 года назад
Glad it was helpful!
@joshuapitong899
@joshuapitong899 2 года назад
Thank you ❤
@programmingelectronics
@programmingelectronics 2 года назад
Thanks for watching!
@venkatchowdary
@venkatchowdary 4 года назад
bro i need one clarity will you help me
@ThuanDuong-pv3xu
@ThuanDuong-pv3xu 4 года назад
to: Programming Electronics Academy I ask mysefl that the ATmega328 , 16 MHz crytal ; It will enforcement 16 million structrures per second so...16M/12 structrures to print the sentence "Ice Ice Baby" are 1,333,333 time per second ( mean Can It print 1,333,333 sentences "Ice Ice Baby" per second ?)
@DaleDix
@DaleDix 4 года назад
Want a pat on the head?
@ebeb9156
@ebeb9156 3 года назад
No. You created serial communication with 9600 changes per second, which in ideal world could be 9600 bit persecond speed. Even if i consider that 100% of data sended where actual words IceIcebaby, still, we got 10 letters(char) ,which are 10*8 =80 bits . 80/9600 this is what you idealy can send to screen, if you write drivers by yourself , without silence/parity check/stop bit and etc . Not all bits you send are part of data, some used for communication purposes. Moreover not really sure that every clock event instruction execute for every arduinos, are all of them "arm" based?
@robbs96
@robbs96 5 лет назад
LMAO! SNL reference. NICE DUDE!
@camilobregon
@camilobregon 4 года назад
THICK L00P
@PleaseWait...
@PleaseWait... 3 года назад
Can i put delay on a for loop?
@programmingelectronics
@programmingelectronics 3 года назад
Great questions! Yes, you can.
@PleaseWait...
@PleaseWait... 3 года назад
@@programmingelectronics alright
@brucesmith9144
@brucesmith9144 4 года назад
Easy to spel??? Oops! Missed an “l” there.
@mikenco
@mikenco 4 года назад
You didn't get the joke, huh?...
Далее
Обменялись песнями с POLI
00:18
Просмотров 110 тыс.
ТАРАКАН
00:38
Просмотров 1,6 млн
Optimizing Arduino Code: no setup(), no loop() ⛔
9:27
Arduino Sketch with millis() instead of delay()
14:27
Просмотров 229 тыс.
Arduino millis() function: 5+ things to consider
12:49
Просмотров 140 тыс.
Coding Was Hard Until I Learned THESE 5 Things!
7:40
7 Arduino Tips for New Programmers
9:41
Просмотров 47 тыс.
I learned to code from scratch in 1 year. Here's how.
41:55
How to Organize Code
14:37
Просмотров 62 тыс.
Using Arrays with For Loops
17:24
Просмотров 32 тыс.
Обменялись песнями с POLI
00:18
Просмотров 110 тыс.