-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-matrix_smile.c
77 lines (61 loc) · 1.13 KB
/
06-matrix_smile.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
unsigned char i;
unsigned char j;
unsigned char result;
int Max7219_pinCLK = 10;
int Max7219_pinCS = 9;
int Max7219_pinDIN = 8;
char array1[90];
unsigned char blarg_xpm[8][8]={
"........",
"........",
"..*..*..",
"........",
".*....*.",
"..****..",
"........",
"........",
};
void my_print(char *a)
{
int i;
for (i = 0; i < 8 && *a != '\0'; i++) {
if (*a == '.') {
result = (result << 1) | 0;
} else {
result = (result << 1) | 1;
}
}
}
void Write_Max7219_byte(unsigned char DATA)
{
unsigned char i;
digitalWrite(Max7219_pinCS,LOW);
for(i=8;i>=1;i--)
{
digitalWrite(Max7219_pinCLK,LOW);
digitalWrite(Max7219_pinDIN,DATA&0x80);
DATA = DATA<<1;
digitalWrite(Max7219_pinCLK,HIGH);
}
}
void Write_Max7219(unsigned char address,unsigned char dat)
{
Write_Max7219_byte(address);
Write_Max7219_byte(dat);
digitalWrite(Max7219_pinCS,HIGH);
}
int a;
void setup()
{
pinMode(Max7219_pinCLK,OUTPUT);
pinMode(Max7219_pinCS,OUTPUT);
pinMode(Max7219_pinDIN,OUTPUT);
}
void loop()
{
for(j=0;j<8;j++)
{
for(i=1;i<9;i++)
Write_Max7219(i,blarg_xpm[j][i-1]);
}
}