1#include <LedControl.h>
2
3const int DIN = 12;
4const int CS = 11;
5const int CLK = 10;
6
7
8
9
10
11byte One[8] = {0x00,0x00,0x88,0x84,0xFE,0x80,0x80,0x00,};
12byte Two[8] = {0x00,0x00,0x88,0xC4,0xA4,0x94,0x88,0x00,};
13byte Three[8] = {0x00,0x00,0x82,0x91,0x91,0xA9,0xEE,0x00,};
14byte Four[8] = {0x00,0x00,0x3F,0x20,0x20,0x20,0xFF,0x20,};
15byte Five[8] = {0x00,0x00,0x9F,0x91,0x91,0x91,0x61,0x00,};
16byte Six[8] = {0x00,0x00,0x78,0x8C,0x8A,0x89,0x71,0x00,};
17byte Seven[8] = {0x00,0x81,0x41,0x21,0x11,0x09,0x07,0x01,};
18byte Eight[8] = {0x00,0x6E,0x91,0x91,0x91,0x91,0x6E,0x00,};
19byte Nine[8] = {0x00,0x06,0x09,0x09,0x09,0xFE,0x00,0x00,};
20byte Ten[8] = {0x04,0x02,0x01,0xFF,0x00,0xFF,0x81,0xFF,};
21byte Eleven[8] = {0x04,0x02,0xFF,0x00,0x04,0x02,0xFF,0x00,};
22byte Twelve[8] = {0x04,0x02,0xFF,0x00,0xE4,0x92,0x8A,0x84,};
23byte Thirteen[8] = {0x04,0x02,0xFF,0x00,0x82,0x92,0x92,0xFE,};
24byte Fourteen[8] = {0x04,0x02,0xFF,0x00,0x1E,0x10,0x10,0xFE,};
25byte Fifteen[8] = {0x04,0x02,0xFF,0x00,0x9E,0x92,0x92,0xE2,};
26byte Sixteen[8] = {0x04,0x02,0xFF,0x00,0xFE,0x92,0x92,0xE2,};
27byte Error[8] = {0x7F,0x49,0x49,0x00,0x7F,0x0D,0x77,0x00,};
28
29LedControl lc=LedControl(DIN,CLK,CS,0);
30
31void setup(){
32 lc.shutdown(0,false);
33 lc.setIntensity(0,1);
34 lc.clearDisplay(0);
35 Serial.begin(9600);
36}
37
38void loop(){
39
40 int Number = analogRead(A0);
41 int checknum = Number/64+1;
42 if(checknum == 1){
43 printByte(One);
44 }else if(checknum == 2){
45 printByte(Two);
46 }else if(checknum == 3){
47 printByte(Three);
48 }else if(checknum == 4){
49 printByte(Four);
50 }else if(checknum == 5){
51 printByte(Five);
52 }else if(checknum == 6){
53 printByte(Six);
54 }else if(checknum == 7){
55 printByte(Seven);
56 }else if(checknum == 8){
57 printByte(Eight);
58 }else if(checknum == 9){
59 printByte(Nine);
60 }else if(checknum == 10){
61 printByte(Ten);
62 }else if(checknum == 11){
63 printByte(Eleven);
64 }else if(checknum == 12){
65 printByte(Twelve);
66 }else if(checknum == 13){
67 printByte(Thirteen);
68 }else if(checknum == 14){
69 printByte(Fourteen);
70 }else if(checknum == 15){
71 printByte(Fifteen);
72 }else if(checknum == 16){
73 printByte(Sixteen);
74 }else{
75 printByte(Error);
76 }
77
78
79
80}
81
82
83void printByte(byte character [])
84{
85 int i = 0;
86 for(i=0;i<8;i++)
87 {
88 lc.setRow(0,i,character[i]);
89 }
90}
91