Tag

arduino

Browsing

Getting programming questions answered on the internet can be problematic. Programmers love to have opinions, stick to those ideas, and express them to you even when their opinion has nothing to do with your question(s).

Not only am I going to explain how to use flag variables in your code, I am going to encourage their use—which most programmers avoid.

However, this advice comes with two caveats.

  1. This information only applies to limited resource environments like an Arduino, LaunchPad or PIC.
  2. Use flag variables very carefully when you do use them.

The following flag variable usage examples are Arduino-centric but apply to any microcontroller platform, including the Energia project for TI Launchpads.

The other day my friend called me up. He told me how much he missed building circuits and wanted to start again with the Arduino.

So he asked me “which Arduino starter kit is the best to buy?” At which point, I drew a long breath. Easy question, not always an easy answer.

Picking out an electronics kit depends on a number of factors. You should consider:

  1. Your budget
  2. What you already have
  3. What you want to do

#1 and #2 are probably pretty easy to figure out. For many beginners, it’s “not much” and “nothing.” When you don’t know #3, what you want to do, then it gets trickier. Coming back to my friend, what did I do? Well, I went out and bought each one of the kits in this post. I put myself in his shoes and maybe these are your shoes as well.

Assuming you have about $100 to spend, have no components on-hand now and just want to “get started” consider one of these 4 Arduino starter kits.

How to blink (or flash) a LED without delay() and detect button pushes

One of the limitations of the delay() function is that nothing else can really be done. This presents a problem when you want to flash a LED while waiting for a pushbutton to be pressed.

Flashing the LED with millis() and using a flag variable to find if the LED should be flashing solves this problem.

Consider this another example to my virtual millis() cookbook.

This code (below) should work with both Arduino (AVR) and Energia (supported boards), but to be honest, I haven’t had a chance to test it on my MSP430 yet.

What was one of the first things you were taught, when learning to program?  “Comment Your Code!”  And of course, like all programming students, you ignored that advice.  Or, if you are like me, you made vague comments as the lines of “variable called var.”

Tonight I opened up some code I haven’t touched in two years.  Code that when I wrote it, made perfect sense to me… at the time.

The code was for my binary clock project, BinBoo.  So I need your help, check out the code below and see if you can help me remember what it does!