2 /**************************************************************
4 * Sample sketch for driving 24x16 LED PANEL (1/4 scan) with
6 * Support for multiple cascaded panels
7 * Get text TO DISPLAY from the serial monitor
8 * http://blog.vettore.org/building-a-large-led-sign-with-inexpensive-standard-modules-and-arduino/
10 *************************************************************/
18 //Pins specific for Mega.See Arduino SPI for a different board.
26 //number of cascaded panels
29 //row to be shown (1-4 since it is 1/4 scan)
32 //brightness: increase->more bright
37 //buffer 8 characters for N_PANELS
41 byte stringDisp[8*N_PANELS]={
42 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','0','1','2','3','4','5','6','7',
47 //pixBuffer reserved space for N_PANELS
48 //contains status of every single pixel in our display!
49 byte pixBuffer[8*8*N_PANELS]={
66 //first timer is the refresh rate for the 1/4 scan
68 //second timer is for change display text IF INPUT AVAILABLE
69 t1.every(1000,checkInput);
83 //diplay alternatively the 4 scan lines
93 //Load and show row (1-4) i.e. 1-5-9-13, 2-6-10-14.....
94 void showRow(int row){
96 int col=0;//is a column of 2 chars
98 for(col=0;col<4*N_PANELS;col++){//show 2 characters every cicle
99 SPI.transfer(~(pixBuffer[row+(col*8)+4+(32*N_PANELS)]));
100 SPI.transfer(~(pixBuffer[row+(col*8)+(32*N_PANELS)]));
101 SPI.transfer(~(pixBuffer[row+(col*8)+4]));
102 SPI.transfer(~(pixBuffer[row+(col*8)]));
105 digitalWrite(STB,LOW);
106 digitalWrite(STB,HIGH);
108 scanrow(row);//enable encoder for the line loaded
110 //PWM like. Change br to adjust brightnes
111 digitalWrite(OE,HIGH);
112 delayMicroseconds(br);//PWM per aggiustare luminosità
113 digitalWrite(OE,LOW);
114 delayMicroseconds(900);
117 //enable encoder for this row in order to show it
137 //check if input from the serial monitor is available
138 //and update the display
139 void checkInput(void){
142 if(Serial.available()){
145 for(h=0;h<(8*N_PANELS);h++)stringDisp[h]=32;
147 while (Serial.available() > 0) {
148 // read the incoming byte:
149 incomingByte = Serial.read();//only UP to the efective string length
150 if(x<(8*N_PANELS)) stringDisp[x]=incomingByte;
158 //load buffer with character pixels of the string
159 //performing a lookup on the FONT table
160 void loadBuffer(void){
163 for(y=0;y<(8*(N_PANELS));y++){
165 pixBuffer[x+8*y]=font[8*stringDisp[y]+x-(31*8)];//char under <=31 not defined