Here is the code and documentation for the Ladies and Mens room mixup project: http://halfmachine.dk/posts/60 in there you´ll find a link with the Wiring code of the project which uses the sparkfun backpack RGB led matrix. I´ll add an example soon. Best, H.
These 3 functions are the core of using the display (you can use any 3 Wiring pins with the display):
int bits[8] = { 128, 64, 32, 16, 8, 4, 2, 1 };
int clock = 16; // pin SCK del display int data = 18; // pin DI del display int cs = 19; // pin CS del display
void drawFrame(byte frame[8][8]) { digitalWrite(clock, LOW); //sets the clock for each display, running through 0 then 1 digitalWrite(data, LOW); //ditto for data. delayMicroseconds(10); digitalWrite(cs, LOW); //ditto for cs. delayMicroseconds(10); for(int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { writeByte(frame[x][y]); //Drawing the grid. x across then down to next y then x across. delayMicroseconds(10); } } delayMicroseconds(10); digitalWrite(cs, HIGH); }
//prints out bytes. Each colour is printed out. void writeByte(byte myByte) { for (int b = 0; b < 8; b++) { //converting it to binary from colour code. digitalWrite(clock, LOW); if ((myByte & bits[b]) > 0) { digitalWrite(data, HIGH); } else { digitalWrite(data, LOW); } digitalWrite(clock, HIGH); delayMicroseconds(10); digitalWrite(clock, LOW); } }
void matrixInit() { pinMode(clock, OUTPUT); // sets the digital pin as output pinMode(data, OUTPUT); pinMode(cs, OUTPUT); }
IP Logged
|