3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

watch futurama on an 8x8 pixel screen

Step 7Draw a frame

the data is stored in arrays of unsigned chars, which are 8 bit numbers. PROGMEM forces the data to be stored in program memory, rather than allowing the avr to copy all of the data to ram. the purpose here is to reduce the number of steps involved and to maximize the amount of info that can be stored and quickly retrieved.

unsigned char green_vals[][8] PROGMEM = { { 0x01, 0xff, 0x80, 0xff, etc...unsigned char red_vals[][8] PROGMEM = { { 0x01, 0x02, 0x03, 0x04, etc...

remember that the matrix is only 8 leds across, meaning that each entry in those arrays corresponds to a complete description of an entire row. so looping through 8 of them in succession is a frame...

for (i=0; i<8; i++){  set_frame( red_vals[ 0 ][ i ], green_vals[ 0 ][ i ], (1<<i) );  show_frame( TIME_TO_SHOW_LINE );}

except that won't work, because of PROGMEM up there... just call pgm_read_byte() on red_vals and green_vals to fix it.

set_frame( pgm_read_byte( &red_vals[ 0 ][ i ] ), pgm_read_byte( &green_vals[ 0 ][ i ] ), (1<<i) );

the set_frame() function is pretty simple:
/* send frame line data to shift registers and set appropriate grounder pin */void set_frame ( unsigned char red, unsigned char green, unsigned char gnd ){	/* just a loop variable */	unsigned char i = 0;		/* set up red, loop through all 8 bits */	for (i=0; i<8; i++)	{		if ( red & (1<<i) ) PORTB |= red_ser;	// if it's a one then serial pin hi		else PORTB &= ~red_ser;			// otherwise make sure it's low		if ( green & (1<<i) )  PORTB |= green_ser;   // if it's a one then pin hi		else  PORTB &= ~green_ser; 	// otherwise make sure it's low		PORTB |= ser_sck;	// clock up		PORTB &= ~ser_sck;	// clock down         }        PORTB &= ~red_ser;		// be sure to leave red's ser line low	PORTB &= ~green_ser;		// leave green serial pin low	/* set the grounder pin for this frame line to low */	PORTD = ~gnd;		// upsidedown logic... }
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2
Followers
1
Author:sethj