Tag

arduino

Browsing

A popular LED project is the “Larson Scanner.”  This scanner emulates the effect seen on KIT from Knight Rider and the Cylons in Battlestar Galactica.  The code is usually written using “delay()” which means you can’t combine it with anything else.  The following code could be put into a function, called periodically and allow your code to scan while doing other things.

By far one of the most powerful functions of the Arduino library is the millis() counter. It is also one of the most misunderstood functions. Mastering millis() can unlock incredible amounts of potential with an Arduino. That’s why I’m spending an entire week on millis().

Each day this week I’m posting a new example of how to use millis() in your code. Each will be cataloged on this newly created Arduino Millis() Cookbook Page. If you have ideas for other examples, leave comments below.

Also, quick note. In doing this work I realized there was some issues with my previous Multitasking with Millis and How to Reset Millis() (hint, you don’t) posts which I’ve now corrected.

It’s 3am but you are not going to bed until you squash this last bug. You sprinkle Serial.print() statements everywhere you can think of, and then that’s when all hell breaks loose:  Your code randomly locks up, the LEDs go crazy, and you’ve had it. What’s going on?  You’ve run out of RAM!