THE
PUBLIC
SCHOOL

TELIC ARTS EXCHANGE

  • CLASS NOTES 256: 8-bit Lab LEDs

May 23, 2009

What is L.E.D.?

LED or light-emitting diode is a "solid state" electronic light source made with a semiconductor diode. When current is applied to the diode, it releases energy in the form of electroluminescence with a color determined by the band gap property of the semiconductor material.

       

LEDs have some advantages over traditional light sources including lower energy consumption, longer lifetime, small size and fast switching, but they are relatively expensive.

Optical Properties of LEDs

The main properties you're going to be looking for when choosing LEDs are probably wavelength and brightness or luminous intensity.

Wavelength of the light determines its color. In the visible spectrum, blue is around 470nm (nanometers), green is 520-570nm, and red is near 630nm. Beyond this wavelength we enter the InfraRed spectrum, which is invisible to the eye (but not your TV).

LED brightness is expressed in mcd (milli-candela) units. A typical inexpensive LED may be rated 10-20mcd. For a brighter output, look for part numbers that list luminous intensity of at least 30mcd. Usually these will be specifically labeled as "ultrabright", "superbright", etc, by the retailer.

The maximum brightness of a particular color has to do with the choice of semiconductor material that is used in the manufacture of an LED. For example, InGaN or AlInGaP are materials used in some high-brightness LEDs. Look for these terms in the datasheet.

The physical package of an LED will have an effect on its brightness and light quality. The datasheet will usually show a graph of light intensity mapped against the viewing angle. Typically, small surface mount LEDs have a wider spread (about 120 degrees), while parts with a dome-shaped lens will be more narrowly focused.

     

 

LED in a Circuit

We turn on the LED and change its brightness by setting the current that flows through it using a Resistor, according to Ohm's law (V = IR).

In order to drive a high-power LED, LED cluster or several LEDs at once, we can use a transistor.

   

http://www.st.com/stonline/products/literature/ds/12292.pdf - TIP31A Transistor Datasheet

We can control several LEDs using Arduino's outputs, including 6 independent PWM channels that let us set brightness with the analogOut command. In order to get more lights connected to the microprocessor, specialized chips come in handy..

74HC595 8-bit Shift Register

This is a chip that takes serial data input using three dedicated lines and outputs it on 8 parallel lines. We can also chain multiple shift registers together to increase the number of outputs further.

     

	
    int latchPin = 8;         // pin connected to RCLK (pin 12) of 74HC595
    int clockPin = 12;        // pin connected to SRCLK (pin 11) of 74HC595
    int dataPin = 11;         // pin connected to SER (pin 14) of 74HC595

    void setup() 
    {
       pinMode(latchPin, OUTPUT);
       pinMode(clockPin, OUTPUT);
       pinMode(dataPin, OUTPUT);
    }

    void loop() 
    {
       for (int j = 0; j < 256; j++) 
       {
    	  digitalWrite(latchPin, LOW);                  // hold latchPin low while transmitting
    	  shiftOut(dataPin, clockPin, LSBFIRST, j);     // shift out the byte  
    	  digitalWrite(latchPin, HIGH);                 // latchPin high when done
    	  delay(1000);
       }
    } 
	
	

http://www.arduino.cc/en/Tutorial/ShiftOut - Arduino shift register tutorial
http://focus.ti.com/lit/ds/symlink/sn74hc595.pdf - 74HC595 Datasheet

TLC5940 16-channel Led Driver

TLC5940 is a 16-channel LED driver with a 12-bit (4096-step) PWM brightness control. Each channel is configured in hardware as a current sink, so we can hook up LEDs directly without resistors. Instead, the chip uses one resistor to set maximum current for all channels.

An Arduino library package is available for TLC5940, which we'll use it to test this part. Follow the link below to download it, unzip the package and place it in hardware/libraries/ within your Arduino application directory. Restart the application, then open and run File > Sketchbook > Examples > Library-Tlc5940 > BasicUse

http://www.arduino.cc/playground/Learning/TLC5940 - Arduino TLC5940 tutorial
http://code.google.com/p/tlc5940arduino - Arduino library for TLC5940
http://focus.ti.com/lit/ds/symlink/tlc5940.pdf - TLC5940 Datasheet

MAX7219

MAX7219 is a serially interfaced common-cathode display driver designed to control 8 digits of 7-segment displays or an 8x8 LED matrix. This chip is designed with 8 current source outputs for connecting directly to the LED anodes (labeled SEG A - SEG G) and 8 current sinks for common cathode connections (DIG 0 - DIG 7). One resistor on Pin 18 (ISET) sets the maximum current for the LEDs.

     

A library for MAX7219 (called "Matrix") is bundled with Arduino by default, so we can use an existing example to start with: File > Sketchbook > Examples > Library-Matrix > hello_matrix. Make a couple of modifications to run it:

  • Change the 0, 1, 2 pins to 2, 3, 4 to avoid conflict with Arduino serial lines
  • Replace a few myMatrix.write statements with code for some display patterns

    #include <Sprite.h>
    #include <Matrix.h>

    /* Arduino - MAX7219 connections: */
    // pin 2: data  - pin 1: DIN
    // pin 3: load  - pin 12: LOAD
    // pin 4: clock - pin 13: CLK
    
    // create a new Matrix instance (data, clock, load)
    Matrix myMatrix = Matrix(2, 4, 3);    

    void setup()
    {
        pinMode(2, OUTPUT);
        pinMode(3, OUTPUT);
        pinMode(4, OUTPUT);
    }

    void loop()
    {
        // clear display
        myMatrix.clear();                           
        delay(1000);
  
        // turn all on
        for(int j=0; j<8; j++)
            for(i=0; i<8; i++)
                myMatrix.write(i, j, HIGH);          
  
        myMatrix.clear();
        delay(1000);
        
        // diagonal cross pattern
        for(int j=0; j<8; j++)
            for(i=0; i<8; i++)
                if(i == j || i == (8-j))             
                    myMatrix.write(i, j, HIGH);      
    }
	

http://www.arduino.cc/playground/Main/MAX72XXHardware - Arduino MAX7219 tutorial
http://datasheets.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf - MAX7219 Datasheet

LED Products Vendors

You don't really need to know anything we've learned in this class to make LED displays on a large scale! There are many products out there that connect directly to your PC monitor port and map a part the screen to drive full-color displays.

ColorKinetics, now owned by Philips, was one of the first companies to offer slick integrated solutions for LED displays of all shapes and sizes.

   
   

ElementLabs is another big company with a really wide product range. They seem to have a lock on lighting control solutions for many music events these days..

   

 

Parts List

Bill of materials used in this workshop, minus the miscellaneous parts we already had in stock.

ITEM DESCRIPTION PRICE
G15529A 5mm Blue LEDs (pkg of 100) $25.00
G440R Resistor 220ohm 1/4W (pkg of 100) $3.50
TIP31A 3A NPN Transistor TO-220 $0.37
TLC5940 4096 Step Grayscale LED Driver $4.27
74HC595 8-bit Shift Register $0.59
74HC4051 8-bit Multiplexer $0.47
MAX7219 8-digit LED Display Driver $10.81

 

Additional Resources

http://superbrightleds.com - wide selection of bright and high-power LEDs
http://www.hebeiltd.com.cn - Chinese vendor with good pricing and an English website ($25 minimum order)