Arduino millis() – The Beginners Guide to multi-tasking with Arduino using millis()

Arduino millis() or delay() – which should I use? How can I time multiple events with Arduino? How can I multi-task with Arduino? Can I still get inputs and have timed events? What is a hardware clock anyway?

So many questions about Arduino timing…so little time?

Which is why we created this Ultimate Guide to using the Arduino millis() function.

We have created 6 in-depth video lessons that include written tutorials and code as well – all covering using millis() and delay()

Below are links and topics covered in this mini-series training:

Lesson 1: millis() Arduino Function: 5+ things to consider

Topics covered:

  • What is a hardware clock?
  • Timer/Counter() modules
  • How to “get” the value from millis()
  • Storing the value of millis()
  • Doing math with unsigned longs (variables that are perfect for storing millis values)

millis() arduino function as headline, with colorful timer icon at top and programming electronics logo

Lesson 2: delay() Arduino Function: Tight loops and blocking code

Topics covered:

  • Tight loops
  • Blocking code

Blue hexed background with Arduino milli() written on it, and picture of programming electronics academy logo and a stop watch

Lesson 3: millis() vs delay()

Topics covered:

  • The simple timed event
  • The not so simple timed event

programming electronics academy logo, picture of stopwatch and title millis() vs. delay

Lesson 4: When delay() should be millis() instead

Topics covered:

  • Issues with inputs and delay()

cartoon picture of timer and title reads millis vs delay part 4, logo for programming electronics academy in top left corner

Lesson 5: Arduino Sketch with millis() instead of delay()

Topics covered:

  • Quick review of the millis function
  • The millis timeline
  • Create once-off timed events
  • Create repetitive timed events

programming electronics logo, millis() in big letters

Lesson 6: Doing multiple timed things with Arduino: Unleash the millis()!

Topics covered:

  • Map out a program with 2 INDEPENDENT timed events
  • Code from scratch a program using millis() to time 2 repetitive events

Banner of Arduino millis function

 

 

Have more questions about using millis()? Let us know in the comments below!

installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

6 Comments

  1. […] post Arduino millis() – The Beginners Guide to multi-tasking with Arduino using millis() appeared first on Programming Electronics […]

  2. John Page on December 9, 2019 at 7:42 pm

    Clear and effective teaching presentation. Thankyou. I’m finally beginningto learn and understand a little Arduino C++ thinking and reasoning.

  3. Okoye Franklin on July 7, 2020 at 6:44 pm

    Please sir, is any site, I can get how to read Analog voltage, on microC compiler thanks.

  4. Nick van Nieuwenhuysen on July 24, 2020 at 12:47 am

    I am impressed by your video’s but I am at an age where I have to repeat the info multiple times before it sticks. Would you consider printing al these fantastic wisdom in book form?

  5. Steve on November 30, 2022 at 12:58 am

    So how did you get the cardboard cutout to blink eyes and run servo at the same time? Or is this not actually possible (just one after the other)?

    • Michael James on November 30, 2022 at 12:35 pm

      Great question Steve! Yes, it is possible, using millis(). If you watch all the lessons referred to in this post, it should help walk you through it. Best of luck!

Leave a Comment