volatile char *outA = (char*)0x22; // rows
volatile char *outB = (char*)0x25; // columns
void setup()
{
volatile char *ddrA = (char*)0x21;
volatile char *ddrB = (char*)0x24;
*ddrA = 0xFF; // rows output
*ddrB = 0xFF; // columns output
}
void delay_ms()
{
volatile int i;
for (i = 0; i < 3000; i++);
}
// 8x8 pattern for "C" (each byte = row data)
unsigned char C_pattern[8] = {
0x3C, // 00111100
0x42, // 01000010
0x80, // 10000000
0x80, // 10000000
0x80, // 10000000
0x42, // 01000010
0x3C, // 00111100
0x00 // empty row
};
void display_C_shift()
{
int shift, col, repeat;
// Shift from left to right (8 positions)
for (shift = 0; shift < 8; shift++)
{
// Show each shifted position for some time
for (repeat = 0; repeat < 80; repeat++)
{
for (col = 0; col < 8; col++)
{
*outB = 1 << col; // select column
*outA = ~(C_pattern[col] >> shift); // shift bits to move horizontally
delay_ms();
}
}
}
}
void loop()
{
display_C_shift();
}