Inhaltsverzeichnis
LED Matrix Projekt
Goal
The goal is to build up a 32×8 LED matrix with THT parts that you can buy at your local dealer. Currently it uses 4 74HC595 shift registers and 2 4017 decade counter to control the matrix. Controlling the LED matrix should be done with an AtMega32 and an AtMega8 for USB to seriell communication.
Parts needed for the matrix
- 4x 74HC595 shift registers
- 2x 4017 decade counters
- 32x 160 ohm resistors
- 16x 1k ohm resistors
- 2x 5×2 pin headers
- 256x LEDs (color: red)
Parts needed for the controller
Nothing there yet.
USB interface
Short description
The USB interface is build after schematic of http://www.recursion.jp/avrcdc/cdc-232.html and uses the same firmware. The communication between the AtMega8 and the AtMega32 is done via normal UART communication.
To control the LED matrix from the PC, the user must send normal text commands and binary image data.
Command structure
There are two types of commands. Single line commands and block commands. Each command start with a 3 byte header and consists of a 3 byte text command followed by the data.
While single line commands ends with a normal line break, block commands must end with the 3 byte text command followed by the 3 bytes header.
The 3 header bytes read LED.
Format of single line command: LEDCOMMANDDATA
Format of block command: LEDCOMMANDDATACOMMANDLED
Commands
Clear
Clears all pixels on the LED Matrix.
Command: CLR Data: none
Usage: LEDCLR
Set Pixel
Sets one pixel on the LED matrix indicated by X and Y coordinates.
Command: STP Data: COORDINATES (1 Byte)
Usage: LEDSTPCOORDINATES
The lower 5 bits of the coordinates parameter describe the X coordinate to set. The upper 3 bits of the coordinates parameter describe the Y coordinate to set. All counting starts at zero (0 ⇐ X ⇐ 31; 0 ⇐ Y ⇐ 7).
Examples:
- LEDSTP0 (001 10010) Set Pixel at X = 18 Y = 1
- LEDSTPA (010 00001) Set Pixel at X = 1 Y = 2
- LEDSTP! (001 00001) Set Pixel at X = 1 Y = 1
- LEDSTP* (001 01010) Set Pixel at X = 10 Y = 1
Clear Pixel
Clears one pixel on the LED matrix indicated by X and Y coordinates.
Command: CLP Data: COORDINATES (1 Byte)
Usage: LEDCLPCOORDINATES
The lower 5 bits of the coordinates parameter describe the X coordinate to set. The upper 3 bits of the coordinates parameter describe the Y coordinate to set. All counting starts at zero (0 ⇐ X ⇐ 31; 0 ⇐ Y ⇐ 7).
Examples:
- LEDCLP0 (001 10010) Clear Pixel at X = 18 Y = 1
- LEDCLPA (010 00001) Clear Pixel at X = 1 Y = 2
- LEDCLP! (001 00001) Clear Pixel at X = 1 Y = 1
- LEDCLP* (001 01010) Clear Pixel at X = 10 Y = 1
Toggle Pixel
Toggles one pixel on the LED matrix indicated by X and Y coordinates.
Command: TGP Data: COORDINATES (1 Byte)
Usage: LEDTGPCOORDINATES
The lower 5 bits of the coordinates parameter describe the X coordinate to set. The upper 3 bits of the coordinates parameter describe the Y coordinate to set. All counting starts at zero (0 ⇐ X ⇐ 31; 0 ⇐ Y ⇐ 7).
Examples:
- LEDTGP0 (001 10010) Toggle Pixel at X = 18 Y = 1
- LEDTGPA (010 00001) Toggle Pixel at X = 1 Y = 2
- LEDTGP! (001 00001) Toggle Pixel at X = 1 Y = 1
- LEDTGP* (001 01010) Toggle Pixel at X = 10 Y = 1