Export to GitHub

arduino-rgb-pixels - LibraryInstructions.wiki


Introduction

The library works with LED pixels which use the LPD controller chip. There exists several different sizes and shapes, see http://bliptronics.com/items.aspx?cat=4

Each LED takes an int (16 bits) which contains 3 x 5 bits of color data for the LED. Note that different types of modules take the data in different order. I'll come up with a fix for that later :|.

The data for the LEDs is stored in memory and then written out with a call to the show() method. An interrupt routine then writes out the data in the background and your code can continue.

Method calls

initialize(long microseconds, int****DisplayAddress,unsigned int LEDCount , char clkPin, char dPin )

microseconds specifies the delay used for the interrupt which sends out data to the LEDs. The delay is used between bits. Each LED takes 16 bits. Lower delay means your Arduino will burn more time running the interrupts. Too high delay will make LEDs flick/slow to update. You can use a value of 25 here for a nice compromise.

DisplayAddress is a pointer to an array of ints for the LED values.

LEDCount is how many LEDs you are using

clkpin and dpin are the arduino pins to use for clock and data

==show()== Call this to send data out to LEDs. Not a call to this will return immediately whilst the data is output in the background by an interrupt running on timer 1.

unsigned int color(unsigned char r,unsigned char g,unsigned char b)

Pass this method 3 values that are in the range 0 to 31 - these are the brightness values for red, green, blue. Note the order is different for different types of pixels.

setRange(unsigned int startLED, unsigned int endLED, unsigned int color )

Set a range of LEDs to the specified color.

setLEDFast(unsigned int LED, byte rr, byte gg, byte bb)

setLEDFast(unsigned int LED, unsigned int color)

Set a specified LED to a color (you can pass the rgb values or just one int

There are some methods to handle a grid of LEDs. LEDs must be arranged as follows, grid can be any size.

00 05 06 01 04 07 02 03 08 See the translate method in the library if you want to change the way the grid is arranged.

Before use, you must set these two properties accordingly.

gridHeight gridWidth

Then you can use these methods:

setPixel(int x, int y, int color)

line(int x0, int y0, int x1, int y1, unsigned int color)

Draw a line between two coordinates.

box(byte x0, byte y0, byte x1, byte y1, unsigned int color)

Draw an unfilled box, specifiy the top left and bottom right corners.