just something to keep me busy ![]()
using 24 LEDs with 3 74HC595 shift register it can create a text by quickly cycling through the individual lines of the text matrix.
the implementation depends on the SPI library (>=Arduino 0019)
the charset is 24x20/character optimized for this purpose.
i will integrate this into a big room fan to display the temperature and the current time.
result:
http://img831.imageshack.us/img831/1573/arduinorulz.jpg
Sorry for shaky image
not an easy task...
Bread Board Circuit:
http://img831.imageshack.us/img831/130/breadboardarduinoleds.jpg
Code for everybody free to use:
// POV (Persistence of vision) for ARDUINO
// 24 LEDs with 3 74HC595 Shift Register
// by Shaksbeer 2010
#include <SPI.h>
#include "char_matrix.h"
int latchPin = 8;
void setup() {
SPI.begin();
pinMode(latchPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
char str[] = "ARDUINO RULZ ";
showString(str, sizeof(str));
}
void showString( char* str, int len )
{
for (int i=0; i<len; i++)
{
showChar( str[i] );
}
}
void showChar(char chr)
{
mychar* c;
if (chr==' ')
{
digitalWrite(latchPin, 0);
SPI.transfer(0x00);
SPI.transfer(0x00);
SPI.transfer(0x00);
digitalWrite(latchPin, 1);
delay(3);
return;
}
c = getMyChar(chr);
if (c==NULL)
return;
for (int j = 0; j < 20; j++) {
digitalWrite(latchPin, 0);
SPI.transfer((*c)[j][0]);
SPI.transfer((*c)[j][1]);
SPI.transfer((*c)[j][2]);
digitalWrite(latchPin, 1);
delayMicroseconds(500);
}
}
mychar* getMyChar(char chr) {
if (chr>=BIGCHARSTART && chr<=BIGCHAREND)
return &bigchars[(int)(chr-BIGCHARSTART)];
return NULL;
}
char_matrix.h (Letter A as example):
// 24x20 charset for ARDUINO
// by shaksbeer 2010
#define BIGCHARSTART 65
#define BIGCHAREND 90
typedef unsigned char mychar[20][3];
mychar bigchars[] =
{
// A = 65
{
{0,0,0},
{248,0,0},
{255,0,0},
{255,224,0},
{255,254,0},
{15,255,192},
{7,255,252},
{7,159,255},
{7,131,255},
{7,128,63},
{7,128,63},
{7,131,255},
{7,191,255},
{7,255,254},
{63,255,224},
{255,254,0},
{255,240,0},
{255,0,0},
{248,0,0},
{128,0,0},
}
};
EDIT: updated code.