Commit | Line | Data |
---|---|---|
e6e13bcc TM |
1 | #include <LedControl.h> |
2 | ||
3 | LedControl lc=LedControl(16,14,15,2); //datain, clk, load, number of chips | |
4 | ||
5 | /* we always wait a bit between updates of the display */ | |
6 | unsigned long delaytime=250; | |
7 | ||
8 | void setup() { | |
9 | /* | |
10 | The MAX72XX is in power-saving mode on startup, | |
11 | we have to do a wakeup call | |
12 | */ | |
13 | lc.shutdown(0,false); | |
14 | /* Set the brightness to a medium values */ | |
15 | lc.setIntensity(0,15); //0 - 15 | |
16 | /* and clear the display */ | |
17 | lc.clearDisplay(0); | |
18 | } | |
19 | ||
20 | ||
21 | /* | |
22 | This method will display the characters for the | |
23 | word "Arduino" one after the other on digit 0. | |
24 | */ | |
25 | void writeArduinoOn7Segment() { | |
26 | lc.setChar(0,0,'a',false); | |
27 | delay(delaytime); | |
28 | lc.setRow(0,0,0x05); | |
29 | delay(delaytime); | |
30 | lc.setChar(0,0,'d',false); | |
31 | delay(delaytime); | |
32 | lc.setRow(0,0,0x1c); | |
33 | delay(delaytime); | |
34 | lc.setRow(0,0,B00010000); | |
35 | delay(delaytime); | |
36 | lc.setRow(0,0,0x15); | |
37 | delay(delaytime); | |
38 | lc.setRow(0,0,0x1D); | |
39 | delay(delaytime); | |
40 | lc.clearDisplay(0); | |
41 | delay(delaytime); | |
42 | } | |
43 | ||
44 | /* | |
45 | This method will scroll all the hexa-decimal | |
46 | numbers and letters on the display. You will need at least | |
47 | four 7-Segment digits. otherwise it won't really look that good. | |
48 | */ | |
49 | void scrollDigits() { | |
50 | for(int i=0;i<13;i++) { | |
51 | lc.setDigit(0,7,i,false); | |
52 | lc.setDigit(0,6,i+1,false); | |
53 | lc.setDigit(0,5,i+2,false); | |
54 | lc.setDigit(0,4,i+3,false); | |
55 | lc.setDigit(0,3,i+4,false); | |
56 | lc.setDigit(0,2,i+5,false); | |
57 | lc.setDigit(0,1,i+6,false); | |
58 | lc.setDigit(0,0,i+7,false); | |
59 | delay(delaytime); | |
60 | } | |
61 | lc.clearDisplay(0); | |
62 | delay(delaytime); | |
63 | } | |
64 | ||
65 | void loop() { | |
66 | writeArduinoOn7Segment(); | |
67 | scrollDigits(); | |
68 | } |