Arduino Sketch with millis() instead of delay()

preview_player
Показать описание
🤩 FREE Arduino Crash Course 👇👇

We designed this circuit board for beginners!

SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------

Get your Free Trial of Altium PCB design Software
We use Rev Captions for our subtitles

Arduino UNO R3:

Budget Arduino Kits:

Multimeter Options:

Helping Hands:

Soldering Stations:

AFFILIATES & REFERRALS
---------------------------------------------------

FOLLOW US ELSEWHERE
---------------------------------------------------

***Arduino Sketch with millis() instead of delay() written tutorial***
Рекомендации по теме
Комментарии
Автор

Using
previousTime = currentTime;
will introduce an accumulating error. The time to process the code within the if statement will add to the time and accumulate. For just blinking LEDs or some other none critical stuff, no big deal.


But if you simply use:
previousTime += interval;
You've just gotten rid of the cumulative error.

AlienRelics
Автор

This is a great explanation. The visuals really help wrap your head around the concept. Thanks for the vid!

cschmitz
Автор

love the simplicity you bring into the i had been reading up on example codes to understand millis function and scratching my head over and over. I wish i had found this video earlier...

shaswot
Автор

It becomes very easy to learn from you. You make everything looks so simple. Thanks

mariojulio
Автор

what a Legend ! i wish i would of found your videos earlier! Absolutely the best explanation of things. Thank you Sir!

martinest
Автор

This is the best "millis()" tutorial I have ever seen. Thanks so much for explaining everything clearly.

epartsacc
Автор

I have always struggled with this, even with your videos from years ago. I have watched numerous videos and still struggled. This video is simply THE BEST!
You have done so well as an experienced programmer to be able to explain to us newby's how this work is such an easy to understand way.
I have been copying & pasting other peoples bits of code randomly getting results and as my projects get more complicated, that approach does not work.
Well done, you are the best teacher on YouTube for Arduino.
No.1
Numero uno!

johncorbishley
Автор

Thank you for a wholesome explanation! Great stuff!

mykolasbauza
Автор

Very clear explanation - I like that. I have taught some stuff in my one past life...Good job!

vjdav
Автор

I'm an 'old timer', and after a year of struggling with the theory and even the basic concept of 'millis', I've finally 'got it'!
Thank you for the best Arduino 'millis' tutorial, and it's been my good fortune to find it..I look forward to watching more of your videos in future.
John.. Bristol.. UK

johnrees..GEIJ
Автор

Thanks a lot man!
I watched numerous videos, but wasn't able understand the concept of space time along with black holes.
But now I'm confident enough to derive E=mc².💪

AbhishekKanti
Автор

The way you show it will usually work nicely. However, the interval at which you trigger your event will be at least eventInterval, but often just a little bit longer. This is because the loop also takes a little time. Sometimes you may want to be more sure that you always trigger your timed event at an 'exact' multiple of 'eventInterval'. In such cases it's better to update your 'previousTime' with the 'eventInterval', like so:

previousTime = previousTime + eventInterval;

jandobbelsteen
Автор

You are my favourite teacher.
Thanks a bunch 😀

omkarkhade
Автор

Really a great video.great people behind this Job...The visuals make everything so simple.thanks millions

conversationwithgod
Автор

Very clear and simple explanation . Thank you!!

guidoramacciotti
Автор

Wow.. That was the greatest tutorial I have ever seen on youtube...Thank you...

ruwansamanpriya
Автор

I like that the if statement works even when the counter overflows so it'll keep going after 49 days and not miss a beat.

wmrieker
Автор

When you saved me I really love that tutorial it's actually the best thing I've ever watched in the history of our doing it Tori old and I'm not even being hilarious that's the truth thanks man keep up the good work !

amirmatrix
Автор

Very Cool!!


You come out with this video just in time for me to use millis() to toggle between volts and amps on an OLED display (without using delays, delays that long when added up would have made the loop way too long for this project).
It took me a bit to figure out how to write the second section (like this:) (currentTime - previousTime >= interval + interval_1) I added the second interval time so I could set the volts code to display less time than the amps code since that's the one that needs to be read the most, but I got it. I'm sure I will eventually figure out an easier way but it's good for now and I'm proud of it! :-D
The most valuable information in your video series is the fact that the timer continues to count up until the microcontroller is reset or turned off and on again.
I now also realize that I can run more than one program from the same millis() function.
It's kind of like calculating what needs to happen at different times of the day with a certain amount of time for each task. Yeah, I know, probably a screwed up analogy but there it is LOL :-)
Until now I thought that the timer reset each time it was called for.


Thanks!!


Joe

AerialPhotogGuy
Автор

Great. first time explained, first-time understood. thank you very much

naboulsikhalid