/* Tiny Word Clock By Tech Kiwi November 2015 V2 - Fixed Orientation issues V3 - Implement Computer Readout Animation V4 - Implement anumation in new array drawpixels V7 - Implement Slower Animation V9 - Slow down draw effect for animation ---------- An 13x13 Array LEDs have been attach to Mega Digital Pins 53 and below Columns are the anodes Rows are the cathodes --------- Pin numbers: Matrix: * 26 x Digital pins 28 through 53 are used to drive the 13x13 display * Columns X = 52,50,48,46,44,42,40,38,36,34,32,30,28 * Rows Y = 29,31,33,35,37,39,41,43,45,47,49,51,53 * * 150 ohm resister used to protect LEDs on each of the 13 Rows Yaxis */ #include #include #include // a basic DS1307 library that returns time as a time_t // 2-dimensional array of column pin numbers: const int col[13] = { 52,50,48,46,44,42,40,38,36,34,32,30,28 }; // Arduino MEGA 2560 Digital Pin allocation // 2-dimensional array of row pin numbers: const int row[13] = { 29,31,33,35,37,39,41,43,45,47,49,51,53 }; // Arduino MEGA 2560 Digital Pin allocation // 2-dimensional array of pixels: int pixels[13][13]; // Master data array holding LED on position denoted by HIGH = on int drawpixels[13][13]; // Used to copy the master data array and reuse for the transition effect from one screen to the next // Dimmer is the delay in microseconds impacting LED brightness // LDR is across A7 and has an input range of 150 to 900 from Dark to Light respectively int LDR; // The variable dimmer is the duration in Millseconds that each LED is left on before being turned off in the LED array int dimmer = 10; // 300 seems to be the brightest before flicker detected // Refresh variable for RTC // Minute Variable used to test change in time int minchange; // cursor position: int x = 5; int y = 5; void setup() { //Initialize RTC Serial.begin(9600); // while (!Serial) ; // wait until Arduino Serial Monitor opens delay(200); setSyncProvider(RTC.get); // the function to get the time from the RTC setSyncInterval(60); // sync the time every 60 seconds (1 minutes) if(timeStatus()!= timeSet){ Serial.println("Unable to sync with the RTC"); RTC.set(1408278800); // set the RTC to Aug 25 2014 9:00 am setTime(1408278800); } else{ Serial.println("RTC has set the system time"); } // initialize the LED I/O pins as outputs // iterate over the pins: for (int thisPin = 0; thisPin < 13; thisPin++) { // initialize the output pins: pinMode(col[thisPin], OUTPUT); pinMode(row[thisPin], OUTPUT); // take the col pins (i.e. the cathodes) high to ensure that // the LEDS are off: digitalWrite(col[thisPin], LOW); } // initialize the pixel matrix by setting all LED Anodes and Cathodes to LOW: for (int x = 0; x < 13; x++) { for (int y = 0; y < 13; y++) { pixels[x][y] = LOW; } } // initialize the Button I/O pins as Digital Inputs for Increment and Decrement time for manual adjustment of time pinMode(8, INPUT); // Increment time pinMode(9, INPUT); // Decrement time } void loop() { // Read the current date and time from the RTC if (timeStatus() == timeSet) { UpdateDisp(); // hmdmDisplay(); } else { Serial.println("The time has not been set. Please run the Time"); Serial.println("TimeRTCSet example, or DS1307RTC SetTime example."); Serial.println(); delay(4000); } minchange = minute(); // Read the current minute value // Check the ambient light and adjust LED brightness to suit LDR = analogRead(A7); if (LDR <= 100) { dimmer = 1; // Take LDR output and use as basis for dimming display } else { dimmer = LDR/4; // Take LDR output and use as basis for dimming display } // draw the screen: refreshScreen(); // Draw time into Array textblock(); // Name always on display itis(); // IT IS always on display //Decrement Button Pushed if(digitalRead(8) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(8) == LOW){ if(timeStatus() == timeSet){ adjustTime(-60); RTC.set(now() -60); blankscreen(); // Blank out all LEDs } } delay(100); } //Increment Button Pushed if(digitalRead(9) == LOW){ delay(100); // Deboubnce by waiting then checking again if(digitalRead(9) == LOW){ if(timeStatus() == timeSet){ adjustTime(60); RTC.set(now() + 60); blankscreen(); // Blank out all LEDs } } delay(100); minchange = minute(); } delay(1); // If a minute has passed then redraw using animation if(minchange != minute()) { UpdateDisp(); //Update array with laatest time ATransition(); // Implement animation to refresh screen } } /* routines */ void blankscreen() { // initialize the pixel matrix by setting all LED Anodes and Cathodes to LOW: for (int x = 0; x < 13; x++) { for (int y = 0; y < 13; y++) { pixels[x][y] = LOW; } } } void UpdateDisp() { // "Display the time based on current RTC data" if((minute()>4) && (minute()<10)){ // FIVE MINUTES fivemins(); past(); dTo(); dtenmins(); dquarter(); dtwenty(); dhalf(); doclock(); } if((minute()>9) && (minute()<15)) { //TEN MINUTES; tenmins(); past(); dTo(); dfivemins(); dquarter(); dtwenty(); dhalf(); doclock(); } if((minute()>14) && (minute()<20)) { // QUARTER quarter(); past(); dfivemins(); dTo(); dtenmins(); dtwenty(); dhalf(); doclock(); } if((minute()>19) && (minute()<25)) { //TWENTY MINUTES twenty(); past(); dfivemins(); dTo(); dtenmins(); dquarter(); dhalf(); doclock(); } if((minute()>24) && (minute()<30)) { //TWENTY FIVE twentyfive(); past(); dTo(); dtenmins(); dquarter(); dhalf(); doclock(); } if((minute()>29) && (minute()<35)) { // HALF half(); past(); dfivemins(); dTo(); dtenmins(); dquarter(); dtwenty(); doclock(); } if((minute()>34) && (minute()<40)) { //TWENTY FIVE TO twentyfive(); To(); dpast(); dtenmins(); dquarter(); dhalf(); doclock(); } if((minute()>39) && (minute()<45)) { //TWENTY TO twenty(); To(); dfivemins(); dpast(); dtenmins(); dquarter(); dhalf(); doclock(); } if((minute()>44) && (minute()<50)) { // QUARTER TO quarter(); To(); dfivemins(); dpast(); dtenmins(); dtwenty(); dhalf(); doclock(); } if((minute()>49) && (minute()<55)){ // TEN TO tenmins(); To(); dfivemins(); dpast(); dquarter(); dtwenty(); dhalf(); doclock(); } if(minute()>54){ // FIVE TO fivemins(); To(); dpast(); dtenmins(); dquarter(); dtwenty(); dhalf(); doclock(); } if(minute()<5){ // OClock oclock(); dfivemins(); dpast(); dTo(); dtenmins(); dquarter(); dtwenty(); dhalf(); } // Display correct Hour for the clock // Do this by determining if after 30mins past the hour if(minute()<35){ // Hours on the clock if 34 minutes or less past the hour if((hour()==1)||(hour()==13)){ // One Oclock one(); dtwelve(); dtwo(); } if((hour()==2)||(hour()==14)){ // Two Oclock two(); done(); dthree(); } if((hour()==3)||(hour()==15)){ // Three Oclock three(); dtwo(); dfour(); } if((hour()==4)||(hour()==16)){ // four Oclock four(); dthree(); dfive(); } if((hour()==5)||(hour()==17)){ // five Oclock five(); dfour(); dsix(); } if((hour()==6)||(hour()==18)){ // Six Oclock six(); dfive(); dseven(); } if((hour()==7)||(hour()==19)){ // Seven Oclock seven(); dsix(); deight(); } if((hour()==8)||(hour()==20)){ // Eight Oclock eight(); dseven(); dnine(); } if((hour()==9)||(hour()==21)){ // Nine Oclock nine(); deight(); dten(); } if((hour()==10)||(hour()==22)){ // Ten Oclock ten(); dnine(); deleven(); } if((hour()==11)||(hour()==23)){ // Eleven Oclock eleven(); dten(); dtwelve(); } if((hour()==12)||(hour()==0)){ // Twelve Oclock twelve(); deleven(); done(); } } else { // Hours on the clock if 35 minutes or more past the hour if((hour()==1)||(hour()==13)){ // To two Oclock two(); done(); dthree(); } if((hour()==2)||(hour()==14)){ // To three Oclock three(); dtwo(); dfour(); } if((hour()==3)||(hour()==15)){ // To four Oclock four(); dthree(); dfive(); } if((hour()==4)||(hour()==16)){ // To five Oclock five(); dfour(); dsix(); } if((hour()==5)||(hour()==17)){ // To six Oclock six(); dfive(); dseven(); } if((hour()==6)||(hour()==18)){ // To seven Oclock seven(); dsix(); deight(); } if((hour()==7)||(hour()==19)){ // To eight Oclock eight(); dseven(); dnine(); } if((hour()==8)||(hour()==20)){ // To nine Oclock nine(); hi(); // Display hi on screen deight(); dten(); } if((hour()==9)||(hour()==21)){ // To ten Oclock ten(); dnine(); deleven(); dhi(); // Delete hi from screen } if((hour()==10)||(hour()==22)){ // To eleven Oclock eleven(); dten(); dtwelve(); } if((hour()==11)||(hour()==23)){ // To twelve Oclock twelve(); deleven(); done(); } if((hour()==12)||(hour()==0)){ // To one Oclock one(); dtwelve(); dtwo(); } } // Change the Birthday Date here so that you can pesonalise for recipient // Happy Birthday 31st October if((month()==10)&&(day()==17)){ happybirthday(); } else { dhappybirthday(); } // Display Hi at 4pm - 6pm if ((hour()>=16) && (hour()<=18)) { hi(); } else { dhi(); } // Good morning if ((hour()>=6) && (hour()<=9)) { goodmorning(); } else { dgoodmorning(); } // Carpe Diem 10am-12pm if ((hour()>=10) && (hour()<=12)) { carpediem(); } else { dcarpediem(); } // Time to Sleep if (hour()>=23) { timetosleep(); } else { dtimetosleep(); } /* */ } // DISPLAY ROUTINES TO TURN ON LEDS void oclock() { // "oclock" pixels[12][7]=HIGH; pixels[12][8]=HIGH; pixels[12][9]=HIGH; pixels[12][10]=HIGH; pixels[12][11]=HIGH; pixels[12][12]=HIGH; } void twelve() { // "twelve oclock" pixels[12][0]=HIGH; pixels[12][1]=HIGH; pixels[12][2]=HIGH; pixels[12][3]=HIGH; pixels[12][4]=HIGH; pixels[12][5]=HIGH; } void eleven() { // "eleven oclock" pixels[11][7]=HIGH; pixels[11][8]=HIGH; pixels[11][9]=HIGH; pixels[11][10]=HIGH; pixels[11][11]=HIGH; pixels[11][12]=HIGH; } void ten() { // "ten" pixels[11][4]=HIGH; pixels[11][5]=HIGH; pixels[11][6]=HIGH; } void nine() { // "nine" pixels[11][0]=HIGH; pixels[11][1]=HIGH; pixels[11][2]=HIGH; pixels[11][3]=HIGH; } void eight() { // "eight" pixels[10][8]=HIGH; pixels[10][9]=HIGH; pixels[10][10]=HIGH; pixels[10][11]=HIGH; pixels[10][12]=HIGH; } void seven() { // "seven o'clock" pixels[10][3]=HIGH; pixels[10][4]=HIGH; pixels[10][5]=HIGH; pixels[10][6]=HIGH; pixels[10][7]=HIGH; } void six() { // "six o'clock" pixels[10][0]=HIGH; pixels[10][1]=HIGH; pixels[10][2]=HIGH; } void five() { // "five o'clock" pixels[9][7]=HIGH; pixels[9][8]=HIGH; pixels[9][9]=HIGH; pixels[9][10]=HIGH; } void four() { // "Four o'clock" pixels[9][3]=HIGH; pixels[9][4]=HIGH; pixels[9][5]=HIGH; pixels[9][6]=HIGH; } void two() { // "two o'clock" pixels[9][0]=HIGH; pixels[9][1]=HIGH; pixels[9][2]=HIGH; } void three() { // "three o'clock" pixels[8][8]=HIGH; pixels[8][9]=HIGH; pixels[8][10]=HIGH; pixels[8][11]=HIGH; pixels[8][12]=HIGH; } void one() { // "one o'clock" pixels[8][5]=HIGH; pixels[8][6]=HIGH; pixels[8][7]=HIGH; } void past() { // past pixels[8][0]=HIGH; pixels[8][1]=HIGH; pixels[8][2]=HIGH; pixels[8][3]=HIGH; } void To() { // "To" pixels[7][5]=HIGH; pixels[7][6]=HIGH; } void fivemins() { // "Five Minutes" pixels[7][0]=HIGH; pixels[7][1]=HIGH; pixels[7][2]=HIGH; pixels[7][3]=HIGH; } void twenty() { // twenty mins pixels[6][7]=HIGH; pixels[6][8]=HIGH; pixels[6][9]=HIGH; pixels[6][10]=HIGH; pixels[6][11]=HIGH; pixels[6][12]=HIGH; } void twentyfive() { // twenty five mins pixels[6][7]=HIGH; pixels[6][8]=HIGH; pixels[6][9]=HIGH; pixels[6][10]=HIGH; pixels[6][11]=HIGH; pixels[6][12]=HIGH; pixels[7][0]=HIGH; pixels[7][1]=HIGH; pixels[7][2]=HIGH; pixels[7][3]=HIGH; } void quarter() { // quarter pixels[6][0]=HIGH; pixels[6][1]=HIGH; pixels[6][2]=HIGH; pixels[6][3]=HIGH; pixels[6][4]=HIGH; pixels[6][5]=HIGH; pixels[6][6]=HIGH; } void tenmins() { // "ten mins" pixels[5][10]=HIGH; pixels[5][11]=HIGH; pixels[5][12]=HIGH; } void half() { // "Half hour" pixels[5][6]=HIGH; pixels[5][7]=HIGH; pixels[5][8]=HIGH; pixels[5][9]=HIGH; } void happybirthday() { // happybirthday pixels[4][0]=HIGH; pixels[4][1]=HIGH; pixels[4][2]=HIGH; pixels[4][3]=HIGH; pixels[4][4]=HIGH; pixels[4][5]=HIGH; pixels[4][6]=HIGH; pixels[4][7]=HIGH; pixels[3][8]=HIGH; pixels[3][9]=HIGH; pixels[3][10]=HIGH; pixels[3][11]=HIGH; pixels[3][12]=HIGH; } void timetosleep() { // timetosleep pixels[3][0]=HIGH; pixels[3][1]=HIGH; pixels[3][2]=HIGH; pixels[3][3]=HIGH; pixels[3][5]=HIGH; pixels[3][6]=HIGH; pixels[4][8]=HIGH; pixels[4][9]=HIGH; pixels[4][10]=HIGH; pixels[4][11]=HIGH; pixels[4][12]=HIGH; } void carpediem() { // Carpediem pixels[2][0]=HIGH; pixels[2][1]=HIGH; pixels[2][2]=HIGH; pixels[2][3]=HIGH; pixels[2][4]=HIGH; pixels[2][6]=HIGH; pixels[2][7]=HIGH; pixels[2][8]=HIGH; pixels[2][9]=HIGH; } void textblock() { // Personalised Name Text Block pixels[0][7]=HIGH; pixels[0][8]=HIGH; pixels[0][9]=HIGH; pixels[0][10]=HIGH; pixels[0][11]=HIGH; pixels[0][12]=HIGH; pixels[1][7]=HIGH; pixels[1][8]=HIGH; pixels[1][9]=HIGH; pixels[1][10]=HIGH; pixels[1][11]=HIGH; pixels[1][12]=HIGH; } void itis() { // "It Is" pixels[5][0]=HIGH; pixels[5][1]=HIGH; pixels[5][3]=HIGH; pixels[5][4]=HIGH; } void goodmorning() { // Personalised Name Text Block pixels[0][0]=HIGH; pixels[0][1]=HIGH; pixels[0][2]=HIGH; pixels[0][3]=HIGH; pixels[1][0]=HIGH; pixels[1][1]=HIGH; pixels[1][2]=HIGH; pixels[1][3]=HIGH; pixels[1][4]=HIGH; pixels[1][5]=HIGH; pixels[1][6]=HIGH; } void hi() { // Personalised Name Text Block pixels[0][4]=HIGH; pixels[0][5]=HIGH; } // DISPLAY ROUTINES TO TURN OFF LEDS void doclock() { // "oclock" pixels[12][7]=LOW; pixels[12][8]=LOW; pixels[12][9]=LOW; pixels[12][10]=LOW; pixels[12][11]=LOW; pixels[12][12]=LOW; } void dtwelve() { // "twelve oclock" pixels[12][0]=LOW; pixels[12][1]=LOW; pixels[12][2]=LOW; pixels[12][3]=LOW; pixels[12][4]=LOW; pixels[12][5]=LOW; } void deleven() { // "eleven oclock" pixels[11][7]=LOW; pixels[11][8]=LOW; pixels[11][9]=LOW; pixels[11][10]=LOW; pixels[11][11]=LOW; pixels[11][12]=LOW; } void dten() { // "ten" pixels[11][4]=LOW; pixels[11][5]=LOW; pixels[11][6]=LOW; } void dnine() { // "nine" pixels[11][0]=LOW; pixels[11][1]=LOW; pixels[11][2]=LOW; pixels[11][3]=LOW; } void deight() { // "eight" pixels[10][8]=LOW; pixels[10][9]=LOW; pixels[10][10]=LOW; pixels[10][11]=LOW; pixels[10][12]=LOW; } void dseven() { // "seven o'clock" pixels[10][3]=LOW; pixels[10][4]=LOW; pixels[10][5]=LOW; pixels[10][6]=LOW; pixels[10][7]=LOW; } void dsix() { // "six o'clock" pixels[10][0]=LOW; pixels[10][1]=LOW; pixels[10][2]=LOW; } void dfive() { // "five o'clock" pixels[9][7]=LOW; pixels[9][8]=LOW; pixels[9][9]=LOW; pixels[9][10]=LOW; } void dfour() { // "Four o'clock" pixels[9][3]=LOW; pixels[9][4]=LOW; pixels[9][5]=LOW; pixels[9][6]=LOW; } void dtwo() { // "two o'clock" pixels[9][0]=LOW; pixels[9][1]=LOW; pixels[9][2]=LOW; } void dthree() { // "three o'clock" pixels[8][8]=LOW; pixels[8][9]=LOW; pixels[8][10]=LOW; pixels[8][11]=LOW; pixels[8][12]=LOW; } void done() { // "one o'clock" pixels[8][5]=LOW; pixels[8][6]=LOW; pixels[8][7]=LOW; } void dpast() { // past pixels[8][0]=LOW; pixels[8][1]=LOW; pixels[8][2]=LOW; pixels[8][3]=LOW; } void dTo() { // "To" pixels[7][5]=LOW; pixels[7][6]=LOW; } void dfivemins() { // "Five Minutes" pixels[7][0]=LOW; pixels[7][1]=LOW; pixels[7][2]=LOW; pixels[7][3]=LOW; } void dtwenty() { // twenty mins pixels[6][7]=LOW; pixels[6][8]=LOW; pixels[6][9]=LOW; pixels[6][10]=LOW; pixels[6][11]=LOW; pixels[6][12]=LOW; } void dtwentyfive() { // twenty five mins pixels[6][7]=LOW; pixels[6][8]=LOW; pixels[6][9]=LOW; pixels[6][10]=LOW; pixels[6][11]=LOW; pixels[6][12]=LOW; pixels[7][0]=LOW; pixels[7][1]=LOW; pixels[7][2]=LOW; pixels[7][3]=LOW; } void dquarter() { // quarter pixels[6][0]=LOW; pixels[6][1]=LOW; pixels[6][2]=LOW; pixels[6][3]=LOW; pixels[6][4]=LOW; pixels[6][5]=LOW; pixels[6][6]=LOW; } void dtenmins() { // "ten mins" pixels[5][10]=LOW; pixels[5][11]=LOW; pixels[5][12]=LOW; } void dhalf() { // "Half hour" pixels[5][6]=LOW; pixels[5][7]=LOW; pixels[5][8]=LOW; pixels[5][9]=LOW; } void dhappybirthday() { // happybirthday pixels[4][0]=LOW; pixels[4][1]=LOW; pixels[4][2]=LOW; pixels[4][3]=LOW; pixels[4][4]=LOW; pixels[4][5]=LOW; pixels[4][6]=LOW; pixels[4][7]=LOW; pixels[3][8]=LOW; pixels[3][9]=LOW; pixels[3][10]=LOW; pixels[3][11]=LOW; pixels[3][12]=LOW; } void dtimetosleep() { // timetosleep pixels[3][0]=LOW; pixels[3][1]=LOW; pixels[3][2]=LOW; pixels[3][3]=LOW; pixels[3][5]=LOW; pixels[3][6]=LOW; pixels[4][8]=LOW; pixels[4][9]=LOW; pixels[4][10]=LOW; pixels[4][11]=LOW; pixels[4][12]=LOW; } void dcarpediem() { // Carpediem pixels[2][0]=LOW; pixels[2][1]=LOW; pixels[2][2]=LOW; pixels[2][3]=LOW; pixels[2][4]=LOW; pixels[2][6]=LOW; pixels[2][7]=LOW; pixels[2][8]=LOW; pixels[2][9]=LOW; } void dtextblock() { // Personalised Name Text Block pixels[0][7]=LOW; pixels[0][8]=LOW; pixels[0][9]=LOW; pixels[0][10]=LOW; pixels[0][11]=LOW; pixels[0][12]=LOW; pixels[1][7]=LOW; pixels[1][8]=LOW; pixels[1][9]=LOW; pixels[1][10]=LOW; pixels[1][11]=LOW; pixels[1][12]=LOW; } void ditis() { // "It Is" pixels[5][0]=LOW; pixels[5][1]=LOW; pixels[5][3]=LOW; pixels[5][4]=LOW; } void dgoodmorning() { // Personalised Name Text Block pixels[0][0]=LOW; pixels[0][1]=LOW; pixels[0][2]=LOW; pixels[0][3]=LOW; pixels[1][0]=LOW; pixels[1][1]=LOW; pixels[1][2]=LOW; pixels[1][3]=LOW; pixels[1][4]=LOW; pixels[1][5]=LOW; pixels[1][6]=LOW; } void dhi() { // Personalised Name Text Block pixels[0][4]=LOW; pixels[0][5]=LOW; } // Temp test routine void hmdmDisplay(){ // display hmdm on monitor Serial.print(hour()); Serial.println(minute()); Serial.println(day()); Serial.println(month()); } // Function to display each pixel systematically in array void refreshScreen() { for (int w=0; w <4; w++) { // iterate over the rows (Cathodes): for (int thisRow = 0; thisRow < 13; thisRow++) { // take the row pin (Cathode) low: digitalWrite(row[thisRow], LOW); // iterate over the cols (Anodes): for (int thisCol = 0; thisCol < 13; thisCol++) { // get the state of the current pixel; int thisPixel = pixels[thisRow][thisCol]; // when the row is Low and the col is High, // the LED where they meet turns on: digitalWrite(col[thisCol], thisPixel); if (thisPixel == HIGH) { // Delay to make LEDs Brighter delayMicroseconds(dimmer); // Delay to make LEDs Brighter // turn the pixel off: digitalWrite(col[thisCol], LOW); } } // take the row pin high to turn off the whole row: digitalWrite(row[thisRow], HIGH); // delay (1); } } } // Function to display each pixel systematically in array void ATransition() { // Sequentially work through matrix from left to right from top to bottom and where there is a HIGH in the array Draw Screen //Effect is to draw the screen progressively drawing time transitions // initialize the pixel matrix by setting all LED Anodes and Cathodes to LOW: for (int x = 0; x < 13; x++) { for (int y = 0; y < 13; y++) { drawpixels[x][y] = LOW; } } // Personalised Name Text Block drawpixels[0][7]=HIGH; drawpixels[0][8]=HIGH; drawpixels[0][9]=HIGH; drawpixels[0][10]=HIGH; drawpixels[0][11]=HIGH; drawpixels[0][12]=HIGH; drawpixels[1][7]=HIGH; drawpixels[1][8]=HIGH; drawpixels[1][9]=HIGH; drawpixels[1][10]=HIGH; drawpixels[1][11]=HIGH; drawpixels[1][12]=HIGH; for (int A = 0; A < 13; A++) { for (int B = 0; B < 13; B++) { if(pixels[A][B] == HIGH) { // Copy the state of the current pixel to a scratch Array drawpixels for animation purposes drawpixels[A][B] = pixels[A][B]; for (int w=0; w <40; w++) { // iterate over the rows (Cathodes): for (int thisRow = 0; thisRow < 13; thisRow++) { // take the row pin (Cathode) low: digitalWrite(row[thisRow], LOW); // iterate over the cols (Anodes): for (int thisCol = 0; thisCol < 13; thisCol++) { // get the state of the current pixel; int thisPixel = drawpixels[thisRow][thisCol]; // when the row is Low and the col is High, // the LED where they meet turns on: digitalWrite(col[thisCol], thisPixel); if (thisPixel == HIGH) { // Delay to make LEDs Brighter delayMicroseconds(dimmer); // Delay to make LEDs Brighter // turn the pixel off: digitalWrite(col[thisCol], LOW); } } // take the row pin high to turn off the whole row: digitalWrite(row[thisRow], HIGH); } } } } } }