//We always have to include the library #include "LedControl.h" /* Now we need a LedControl to work with. ***** These pin numbers will probably not work with your hardware ***** pin 12 is connected to the DataIn pin 11 is connected to the CLK pin 10 is connected to LOAD We have only a single MAX72XX. */ LedControl lc = LedControl(12, 11, 10, 1); int a = 5000; int b = 599; int c = 66; int d = 7; /* we always wait a bit between updates of the display */ unsigned long delaytime = 250; void setup() { /* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */ lc.shutdown(0, false); /* Set the brightness to a medium values */ lc.setIntensity(0, 15); /* and clear the display */ lc.clearDisplay(0); Serial.begin(9600); } /* This method will display the characters for the word "Arduino" one after the other on digit 0. */ /* This method will scroll all the hexa-decimal numbers and letters on the display. You will need at least four 7-Segment digits. otherwise it won't really look that good. */ void scrollDigits() { lc.setDigit(0, 3, 4, false); lc.setDigit(0, 2, 3, false); lc.setDigit(0, 1, 2, false); lc.setDigit(0, 0, 1, false); } void printNumber(int v) { int ones; int tens; int hundreds; int thousand; if (v < 0 || v > 9999) return; ones = v % 10; v = v / 10; tens = v % 10; v = v / 10; hundreds = v % 10; v = v / 10; thousand = v; //Now print the number digit by digit //lc.setDigit(0,3,(byte)thousand,false); if (thousand == 0) { lc.setChar(0, 3, ' ', false); } else { lc.setDigit(0, 3, (byte)thousand, false); } if ((hundreds == 0) && (thousand == 0)) { lc.setChar(0, 2, ' ', false); } else { lc.setDigit(0, 2, (byte)hundreds, false); } if ((tens == 0) && (hundreds == 0) && (thousand == 0)) { lc.setChar(0, 1,' ', false); } else { lc.setDigit(0, 1, (byte)tens, false); } lc.setDigit(0, 0, (byte)ones, false); } void loop() { //scrollDigits(); //delay(1000); printNumber(a); delay(1000); printNumber(b); delay(1000); printNumber(c); delay(1000); printNumber(d); delay(1000); }