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
9 *************************************************************/
17 //Pins specific for Mega.See Arduino SPI for a different board.
25 //number of cascaded panels
28 //row to be shown (1-4 since it is 1/4 scan)
31 //brightness: increase->more bright
36 //buffer 8 characters for N_PANELS
40 byte stringDisp[8*N_PANELS]={
41 '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',
46 //pixBuffer reserved space for N_PANELS
47 //contains status of every single pixel in our display!
48 byte pixBuffer[8*8*N_PANELS]={
65 //first timer is the refresh rate for the 1/4 scan
67 //second timer is for change display text IF INPUT AVAILABLE
68 t1.every(1000,checkInput);
82 //diplay alternatively the 4 scan lines
92 //Load and show row (1-4) i.e. 1-5-9-13, 2-6-10-14.....
93 void showRow(int row){
95 int col=0;//is a column of 2 chars
97 for(col=0;col<4*N_PANELS;col++){//show 2 characters every cicle
98 SPI.transfer(~(pixBuffer[row+(col*8)+4+(32*N_PANELS)]));
99 SPI.transfer(~(pixBuffer[row+(col*8)+(32*N_PANELS)]));
100 SPI.transfer(~(pixBuffer[row+(col*8)+4]));
101 SPI.transfer(~(pixBuffer[row+(col*8)]));
104 digitalWrite(STB,LOW);
105 digitalWrite(STB,HIGH);
107 scanrow(row);//enable encoder for the line loaded
109 //PWM like. Change br to adjust brightnes
110 digitalWrite(OE,HIGH);
111 delayMicroseconds(br);//PWM per aggiustare luminosità
112 digitalWrite(OE,LOW);
113 delayMicroseconds(900);
116 //enable encoder for this row in order to show it
136 //check if input from the serial monitor is available
137 //and update the display
138 void checkInput(void){
141 if(Serial.available()){
144 for(h=0;h<(8*N_PANELS);h++)stringDisp[h]=32;
146 while (Serial.available() > 0) {
147 // read the incoming byte:
148 incomingByte = Serial.read();//only UP to the efective string length
149 if(x<(8*N_PANELS)) stringDisp[x]=incomingByte;
157 //load buffer with character pixels of the string
158 //performing a lookup on the FONT table
159 void loadBuffer(void){
162 for(y=0;y<(8*(N_PANELS));y++){
164 pixBuffer[x+8*y]=font[8*stringDisp[y]+x-(31*8)];//char under <=31 not defined