😉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!!!!
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.
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.
@@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.
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
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.
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.
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 ?)
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?
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 !!!!!
****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB
Please make a video on how to use arduino timers
I was seriously considering about delay(2000) mean 2 seconds?
Lol I like how the lens was listening music and how you were pouring those components like something to be used for recipe LOL
😉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!!!!
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
Excellent tutorial. Great explanations that clear up any misunderstandings ...and nice sense of humour. Thank you
Thanks Joseph!
Looking forward for the millis(); series. Thanks for sharing your knowledge with us.
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.
Awesome explanations, I really enjoying this approach to teaching.
Thanks so much! Best of luck on your Arduino endeavors!
this is the greatest arduino content ive ever come accross!! Thank you soooo much and keep it up! please :)
Thanks so much for the comment!
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 ?
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.
Hello sir, can I use emonlib with millis function ? It's worked?
Really very help full info and solid info
Glad it was helpful!
I'm curious about your take on branchless programming for tight Arduino loops.
Great question! I have not explored branchless programming much, so I don't really have a take on it quite yet.
@@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.
thank you for explaining
Glad it was helpful!
this is what i need
Thank you ❤
Thanks for watching!
What is "Pay with checks"?
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 😂
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.
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
:)
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.
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.
Can i put delay on a for loop?
Great questions! Yes, you can.
@@programmingelectronics alright
Yeah. Speling is easy ;-)
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 ?)
Want a pat on the head?
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?
Easy to spel. made me laugh :-)
Thanks for watching!
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..???.
bro i need one clarity will you help me
I watched just for the music recipe and didn't get it :p
...So in smartphone We need multi cores, multi threads (hardware) multi functions (software) to play multimedia !!
cheio de humor...kkkk...dah dah duh dah...
I'm trying :)
LMAO! SNL reference. NICE DUDE!
This was delay function.. not miles
THICK L00P
Bathroom Break😂
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 !!!!!
you spelled 'spell' wrong lol
Easy to spel???
Oops! Missed an “l” there.
You didn't get the joke, huh?...