forked from 5cottyD/Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Arduino-8x8-LED-Matrix-Max7219-Code.ino
115 lines (99 loc) · 1.66 KB
/
Arduino-8x8-LED-Matrix-Max7219-Code.ino
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "LedControl.h"
LedControl lc=LedControl(11,9,10,2); // Pin and # of Displays
unsigned long delayTime=200; // Delay between Frames
// Put values in arrays
byte invader1a[] =
{
B00011000, // First frame of invader #1
B00111100,
B01111110,
B11011011,
B11111111,
B00100100,
B01011010,
B10100101
};
byte invader1b[] =
{
B00011000, // Second frame of invader #1
B00111100,
B01111110,
B11011011,
B11111111,
B00100100,
B01011010,
B01000010
};
byte invader2a[] =
{
B00100100, // First frame of invader #1
B00100100,
B01111110,
B11011011,
B11111111,
B11111111,
B10100101,
B00100100
};
byte invader2b[] =
{
B00100100, // Second frame of invader #3
B10100101,
B11111111,
B11011011,
B11111111,
B01111110,
B00100100,
B01000010
};
void setup()
{
lc.shutdown(0,false); // Wake up displays
lc.shutdown(1,false);
lc.setIntensity(0,5); // Set intensity levels
lc.setIntensity(1,5);
lc.clearDisplay(0); // Clear Displays
lc.clearDisplay(1);
}
// Take values in Arrays and Display them
void sinvader1a()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,invader1a[i]);
}
}
void sinvader1b()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,invader1b[i]);
}
}
void sinvader2a()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,invader2a[i]);
}
}
void sinvader2b()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(1,i,invader2b[i]);
}
}
void loop()
{
// Put #1 frame on both Display
sinvader1a();
delay(delayTime);
sinvader2a();
delay(delayTime);
// Put #2 frame on both Display
sinvader1b();
delay(delayTime);
sinvader2b();
delay(delayTime);
}