Why is your LED flickering, fading, or blinking? The beginning of this tutorial mentioned that the LilyTiny was programmed to generate this behavior, but what does that mean?

In the circuit from the bookmark tutorial, you could control the LED by flipping the on/off switch on the battery holder with your finger. If you did this very quickly and carefully you could get the LED to blink in a regular pattern, but it’d be hard work.

On the bracelet, you’ve added a LilyTiny to the circuit. Your circuit is similar to the bookmark circuit except you’ve sewn your LED to the LilyTiny instead of the battery.


You can think of each tab on the LilyTiny as a switch that is controlled by the LilyTiny. In the example below, an LED attached to pin 2 turns on when this switch is closed and turns off when this switch is open.

The LilyTiny opens and closes these switches in patterns specified by a program. What’s cool is that these are incredibly fast switches. Each one can open and close millions of times per second in exactly the way the LilyTiny tells it to. What’s even better is that the LilyTiny is not just one switch, it’s four! Each tab can be programmed with a different pattern.

Think about what these programs might be saying for the different LED behaviors. Start with the simplest behavior, blink— how would you describe the blink behavior if you had to explain it to someone who was flipping a switch? Stop and think about this for a moment and jot down a set of instructions. They should look something like the “program” below.

What about the heartbeat pattern? Can you write out a description of that behavior?

The fading and flickering behaviors are a bit more complex because the LED appears to gradually get dimmer and brighter. Try writing out a program to describe these patterns.

Below is a rough outline of code and its visualization for the tab 0 fading behavior.



In the next tutorial you’ll get to write your own programs to create your own blinking patterns. For now, these examples provide nice insights into why computers are so powerful. Computers can automate annoying repetitive tasks—like flipping a switch over and over. They can work at speeds that are impossible for you to perceive, let alone perform at yourself. They’re tiny and can be embedded into almost anything—even bracelets. And, most importantly, they’re programmable—they do what you tell them to do!

<< PREVIOUS      NEXT >>