4
Did you know that you can build a digital read out (DRO) for a lathe or milling machine? Learn more...

NerdKits - DIY Marquee LED Array Display

  • Upload
    ki-sey

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

NerdKits - DIY Marquee LED Array Display

Citation preview

Page 1: NerdKits - DIY Marquee LED Array Display

1/23/13 NerdKits - DIY Marquee LED Array Display

www.nerdkits.com/videos/ledarray2/ 1/4

DIY Marquee LED Array Display

Have you ever wanted to have one of those big scrolling LED displays, to keep you up to date on e-mails,news, weather, or stock quotes? In this microcontroller project tutorial, we'll show you how to build an arrayof 120 LEDs, how to control them all from one microcontroller, and how to talk to it from your computer.

November 3, 2009:

Welcome, visitors! We had such a tremendous response to this video tutorial that we decided to make it into akit of its own!

Ready to build your own LED array? Find more details on our LED Array Kit page.

- Humberto and Mike

This project makes use of row-column addressing, which lets us control lots of LEDs without having one wire going to each one. We alsouse one more trick -- the fact that diodes only conduct in one direction -- to double the number of LEDs you can handle with theATmega168 microcontroller. There are some schemes that you can use to control even more LEDs (see Charlieplexing), but part of thetradeoff is that the LEDs would be on for a shorter fraction of the time, so they'd be less bright. Engineering is all about making smarttradeoffs: here, we're going with somewhat fewer LEDs, but they'll be brighter and the wiring will be much simpler.

Here's what the finished product looks like:

HOME KITS TUTORIALS PROJECTS ABOUT STORE FORUMS MEMBERS

Did you know that you can build a digital read out(DRO) for a lathe or milling machine? Learn

more...

Page 2: NerdKits - DIY Marquee LED Array Display

1/23/13 NerdKits - DIY Marquee LED Array Display

www.nerdkits.com/videos/ledarray2/ 2/4

Parts List

In addition to our USB NerdKit microcontroller kit and a wall DC adapter, you'll need:

Photo Part Quantity Description

T1-3/4(5mm)standardLEDs

120

Our video shows green LEDs, but you can definitely use other colors. Keep in mind that the anode is thelonger lead, the cathode is the shorter one (also indicated by a flat section on the plastic case, and by thetriangle's tip and line on the schematic), and that current only flows from anode to cathode.

Some example part numbers from Digi-Key: Red LEDs Green LEDs Yellow LEDs

We also used cardboard (roughly 21" by 6"), spray paint, wire (roughly 30-50 feet), and some tissue paper as a display diffuser.

LED Wiring Plan

As described in the video, we make use of row-column addressing, as well as one special trick to double the number of pixels. Thisschematic illustrates the wiring scheme for the 120 LEDs: (click to enlarge)

If you aren't yet familiar with microcontroller basics or microcontroller programming, then what you first need to know is that each of the 12column wires and 5 row wires goes to an input/output (I/O) pin of the microcontroller. The software running on the chip can put the pin in oneof three states: HIGH (driven to +5 volts), LOW (driven to 0 volts), or FLOATING (undriven -- no current in or out). (There is a fourth statewhich has to do with pull-up resistors, but this is not important for now.) If a path from HIGH to LOW exists across any LED in the forwarddirection, current will be allowed to flow, and that LED will light up.

To turn on the top left LED in this schematic, we would make row 0 be LOW, column 0 be HIGH, and simply drive no current onto the otherrow and column wires. For its neighbor one spot to the right, we would make row 0 be HIGH, column 0 be LOW, and not drive the others.The same pattern applies for all of the 5 row and 12 column wires, so that ultimately we can individually control every LED in the array.Row-column addressing, like shown here, is an extremely common way of reducing "pin count" of systems, which allows for simpler wiringand cheaper parts. For example, numeric keypads, like those on a telephone, have a row-column matrix of wires, so that an individual wireper button is not needed.

Also, you should be aware that when using this kind of scheme, we are adding another complexity: time. With any sort of multiplexingscheme like this one, we can control or read lots of outputs or inputs, but we can't do them all at exactly the same time. That's why we havethe microcontroller quickly loop through the various row/polarity combinations, as described more below.

Physical Construction

The physical construction of the LED Array is where you get to be creative. Feel free to explore different backboard materials, differentspacing between the LEDs, even different patterns (who said it had to be a rectangular array). We started off with a piece of cardboard,

Page 3: NerdKits - DIY Marquee LED Array Display

1/23/13 NerdKits - DIY Marquee LED Array Display

www.nerdkits.com/videos/ledarray2/ 3/4

and spray painted it blue. We measured and marked out a grid with spaces 3/4" apart, and drilled small 1/16" holes using a drill press. Weunderstand most people do not have a drill press at home, but a handheld drill should work fine, or even a sharp pencil.

Once you have holes in the back board, you need to put the LEDs through. We chose to run the column wires down the back of the array,and run the row wires across the front. This makes it easier to keep them from touching, and shorting out. In order to be able to drive morecolumns using only one microcontroller we will connect the LEDs using a wiring scheme that takes advantage of the diode properties ofLEDs (see wiring plan above). This means we have to very careful to put the anodes of the LEDs through on the first column, then cathodesof the LEDs through on the second column, and keep alternating all the way down the array. On the back, every two LED columns is twistedtogether with one column wire, and soldered in place. On the front we lay the row wire across the entire row of LEDs, twist the LED pin overthe row wire, and solder it together. You can then cut off the excess LED pin on the front using wire strippers, or diagonal cutters if you havethem.

Click any photo to enlarge:

Display Interrupt Handler

Since we can only actually have 12 of the 120 LEDs on at any time, we have to switch between the sets fast enough that your eyes can notperceive any blinking. For this, we use the ATmega168's Timer0 timer/counter unit, which we have set to count and overflow every 1.1ms.(For more background on the timer/counters on the microcontroller, see our Servo Squirter tutorial page.) We then designate a specialfunction, called an interrupt handler, to be run every time the counter overflows. When this happens, the microcontroller stops whatevercode it's running, and switches to the interrupt handler.

In order to pass information to the interrupt handler, we maintain a big array in memory, which contains information telling us whether eachLED is supposed to be on or off. The normal code flow sets those bits high or low, and the interrupt handler reads the appropriate onesand turns the LEDs on or off. Whenever writing interrupt handler code, you have to be mindful that some variables might get modified bythe interrupt handler, at times when the normal code flow wouldn't expect them. In this case, it isn't a significant issue, because informationonly goes one way -- from normal code to the interrupt handler. But if it were to go the other way as well, we'd have to be careful to use the"volatile" keyword to tell the compiler to make fewer assumptions about those variables.

LED Font

In order for a system like this to be useful for displaying text, you need a way to take characters and transform them into the internal arrayrepresentation of ON/OFF LEDs. In order to abstract this away from the microcontroller code, we wrote a python font maker. This smallprogram reads a file called font.txt which contains a representation of every character using rows of *s. The font maker python code readsthis file and generates a C file called font.h. This font.h file is a giant array which contains every character represented by 5 integers. Eachinteger represents a whole column, and every bit of each integer is a single LED. Depending on whether the bit is high or low, the LEDshould be on or off. Loading font.h into our microcontroller code allows us to retrieve the representation of each character we want todisplay.

Computer to Microcontroller Communication

The computer communicates with the microcontroller through a the serial port. The microcontroller sends a lower case "n" when it is able to

Page 4: NerdKits - DIY Marquee LED Array Display

1/23/13 NerdKits - DIY Marquee LED Array Display

www.nerdkits.com/videos/ledarray2/ 4/4

take a new character. The computer sends the characters one at a time, and the microcontroller scrolls them across the LED display. Wewrote some python code that can accept a connection, and receive text over that socket connection and send it to the LED Array to bescrolled. You can use netcat, to send text to this script, or write your own application that pulls data from the web and pushes it to the LEDArray! For example, you can run:

echo "HI MOM!!!" | netcat localhost 6666

to scroll that text across the display. When the text is done scrolling, the display will return to showing the current time.

Source Code

You can download the source code here. This ZIP file includes both microcontroller-side and PC-side code.

More Videos and Projects!

Take a look at more videos and microcontroller projects!

Comments

Search

NerdKitsHomeKits

ProjectsLibraryAboutStore

Members AreaFeedback

VideosCapacitive Proximity Sensor

C Programming: printf and scanfMotors and Microcontrollers 101

Interrupts & PS/2 KeyboardsUSB Servo-Guided Water Squirter

Valentine's Day LED HeartiPhone-controlled R/C Car

and many more...

Community ForumsBasic Electronics

Customer TestimonialsMicrocontroller ProgrammingNerdKits Newsletter Archives

Project Help and IdeasSensors, Actuators, and Robotics

Support Forumand everything else...

Copyright © 2013 by NerdKits, L.L.C.

This webpage is not available

The webpage at https://www.facebook.com/plugins/comments.php?

api_key=64994793174&locale=en_US&sdk=joey&channel_url=http%3A%2F%2Fstatic.a

k.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D18%23cb%3Df30c17b1f4

%26origin%3Dhttp%253A%252F%252Fwww.nerdkits.com%252Ff1accc0c34%26domain%

3Dwww.nerdkits.com%26relation%3Dparent.parent&numposts=10&width=550&href=ht

tp%3A%2F%2Fwww.nerdkits.com%2Fvideos%2Fledarray2%2F might be temporarily

down or it may have moved permanently to a new web address.