Arduino: Hello World… a first sketch, with 384 LEDs

I picked up an Arduino recently after about two years of lusting for one — just never had time. The standard first program sketch is a blinking LED (see this great Make Magazine video), but the same time I ordered the Arduino I also bought a $10 (shipped from China) 24×16 LED Matrix from Sure Electronics on eBay. So since more is better, of course I want to make all 384 LEDs blink (at random).

Let’s hook it up!

24x16 LED Matrix Wiring (Fritzing)

24x16 LED Matrix Wiring (made using Fritzing)

If you reverse the GND and 5V wiring you will probably blow up the display. The pin numbers are on the back of the display, so be sure to reference those. The connections:

- Arduino Digital Output 12 to pin 1 of the display connector (CS).
- Digital Output 11 goes to pin 5 of the display (WRCLK)
- Digital Output 10 goes to pin 7 of the display (DATA)
- Digital GND goes to pin 11 of the display (GND)
- Power 5v goes to pin 12 of the display (+5V)

arudino_ledmatrix

Now to the software. I found a post by westfw (#94) on Arduino.cc with some sample code that goes through a variety of demos on the display using various contributors’ code. I’m a novice programmer at best, but I took his demo and cut out just the core parts for the display and wrote my own implementation to have the whole matrix select and toggle random LEDs on and off. Download the whole thing here. It’s not pretty, but here’s my hasty code:

void setup ()
{
ht1632_setup();
randomSeed(analogRead(0)); //get some analog static from pin 0 for the random number generator
}

void loop ()
{
int x, y, p;

x=random(24); //pick a random X coordinate
y=random(16); //pick a random Y coordinate
p=random(2); //pick on/off (1 or 0, respectively)

plot(x,y,p); //tell the display to execute the randomness

}

So if you’re vaguely familiar with Arudino (like me at this point) you should be able to plug wires in, run the code, and watch some LEDs blink randomly. Behold the awesome power of microcontrollers!

Related links:

- Sure Electronics DE-DP016 Data Sheet
- Arduino.cc Forum Post on the DE-DP016 (and related displays)

  1. No comments yet.

  1. November 3rd, 2009