Introduction: Knight Rider Animation With Arduino and TLC5940

In this tutorial I will show how to display a 'Knight Rider' animation on a LED bar using an Arduino board and a TLC5940 chip.

For the software I will use the wonderful ALA library so you can play with different animations easily.

Step 1: Parts

The TLC5940 chip is the core of the schema it allows to drive the 10 LEDs at fixed current.

  • Arduino board (I have used an Arduino Uno)
  • Breadboard
  • One TLC5940 chip
  • 10 LED Bar Graph
  • 2.2 K Ohm resistor
  • 10 K Ohm resistor
  • Some jumper wires

Step 2: Schematic

The 2.2K resistor (on pin 9) sets the TLC5940 to drive the LEDs with 20mA current. The 10K pull-up resistor (on pin 6) turns all outputs off while Arduino resets.

Step 3: Code

Instead of developing my own algorithm for the 'Knight Rider' animation, I have decided to use the Arduino Light Animation library. It is very easy to use and it's fun to try all the animations.

First of all you have to install the ALA library from here and put it on your Arduino library folder.

After having installed the library you can use the following sketch.

#include "AlaLed.h"
AlaLed ledBar; byte pins[] = { 1,2,3,4,5,6,7,8,9,10 }; void setup() { ledBar.initTLC5940(10, pins); ledBar.setAnimation(ALA_LARSONSCANNER2, 2000); } void loop() { ledBar.runAnimation(); }

Step 4: Tryout Other Animations

The ALA library offers many animations ready to use. You can also define an animation sequence.

Here are some animations you can use in the setAnimation function: