Here is an example how to connect the FlatPCB cells.
Press the keys to turn on the pins. They are multi use.
#define CLK_H PORTD |= 4 // D2 PD2 --> Clock OUTPUT (yellow)
#define CLK_L PORTD &= ~4
#define STR_H PORTD |= 8 // D3 PD3 --> Strobe OUTPUT (green)
#define STR_L PORTD &= ~8
#define DOUT_H PORTD |= 16 // D4 PD4 --> DataOut (Pins) OUTPUT (blue)
#define DOUT_L PORTD &= ~16
#define DIN PIND & 32 // D5 PD5 <-- DataIn (Keys) INPUT (purple)
const int cellCount = 8;
byte cells [cellCount];
byte keys [cellCount]; // 1 = pressed, 0 = not pressed
void setup()
{
DDRD |= (4 | 8 | 16); // Set as OUTPUT (1=RX, 2=TX, 4=D2, 8=D3, 16=D4, 32=D5, 64=D6, 128=D7)
// DoTests();
}
void loop()
{
RWFlatPCB();
}
void RWFlatPCB()
{
CLK_L;
STR_H; // Strobe on
int index;
for(int i = 0; i < cellCount; i++)
{
if (i & 1) index = i-1; else index = i+1; // change the cells
for(int b = 7; b >= 0; b--)
{
CLK_L; if ( cells[index] & (1<<b) ) {DOUT_H;} else {DOUT_L;} CLK_H;
}
}
// Read the Keys
CLK_L;
STR_L; // Strobe off
for (int i = cellCount-1; i > 0; i--)
{
if ( (DIN) == 0 ) keys[i] = 1; else keys[i] = 0;
CLK_H; CLK_L;
if ( keys[i] == 1 ) cells[i] = 255; else cells[i] = 0; // Turn on the cell
}
STR_H; // Strobe on
}
void DoTests()
{
// Lines down
for(int j = 0; j < 10; j++)
{
for(int i = 0; i < cellCount; i++) { cells[i] = 1 +8; } RWFlatPCB(); delay(100);
for(int i = 0; i < cellCount; i++) { cells[i] = 2 +16; } RWFlatPCB(); delay(50);
for(int i = 0; i < cellCount; i++) { cells[i] = 4 +32; } RWFlatPCB(); delay(20);
for(int i = 0; i < cellCount; i++) { cells[i] = 64+128; } RWFlatPCB(); delay(10);
}
for(int i = 0; i < cellCount; i++) { cells[i] = 0; } RWFlatPCB(); delay(200);
// X-Test
for(int j = 0; j < 10; j++)
{
for(int i = 0; i < cellCount; i++) { cells[i] = 1+16+4+128; } RWFlatPCB(); delay(100);
for(int i = 0; i < cellCount; i++) { cells[i] = 8+2+32+64; } RWFlatPCB(); delay(100);
}
for(int i = 0; i < cellCount; i++) { cells[i] = 0; } RWFlatPCB(); delay(200);
// On-Off
for(int i = 0; i < cellCount; i++) { cells[i] = 255; } RWFlatPCB(); delay(500);
for(int i = 0; i < cellCount; i++) { cells[i] = 0; } RWFlatPCB(); delay(200);
// Every pin
for(int j = 0; j < 10; j++)
{
for(int b = 0; b < 8; b++)
{
for(int i = 0; i < cellCount; i++) { cells[i] = (1<<b); } RWFlatPCB();
}
}
// All off
for(int i = 0; i < cellCount; i++) { cells[i] = 0; } RWFlatPCB();
}
FlatPCB.ino (2.68 KB)

