-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLedMatrix.ino
More file actions
99 lines (88 loc) · 2.74 KB
/
Copy pathLedMatrix.ino
File metadata and controls
99 lines (88 loc) · 2.74 KB
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
/*=====================================================================
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------
Purpose : Drive an 8x8 LED matrix without any IC.
Date : 13 Dec 2015
Boards : ArduinoUno, LaunchPadF5529
=====================================================================
*/
// Adapted from:
// Arduino Cookbook by Michael Margolis. 2011. Section 7.8
// Comment/uncomment as suitable for your hardware
// #define LaunchPadF5529
// Wiring connections from uC to display: (below are pin numbers on display):
// Columns on LED (left to right): 13, 3, 4, 10, 6, 11, 15, 16
// Rows on LED (top to bottom): 5, 2, 7, 1, 12, 8, 14, 9
#ifdef LaunchPadF5529
const int columnPins[] = {P2_5, P2_4, P1_5, P1_4, P1_3, P1_2, P4_3, P4_0};
const int rowPins[] = {P2_0, P2_2, P7_4, P2_6, P2_3, P8_1, P3_7, P8_2};
#else
const int columnPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int rowPins[] = {19, 18, 17, 16, 15, 12, 11, 10};
#endif
#define ROW_CATHODE
#ifdef ROW_CATHODE
#define ROW_ON LOW
#define COL_ON HIGH
#else
#define ROW_ON HIGH
#define COL_ON LOW
#endif
byte bigHeart[] = {
B01100110,
B11111111,
B11111111,
B11111111,
B01111110,
B00111100,
B00011000,
B00000000
};
byte smallHeart[] = {
B00000000,
B00000000,
B00010100,
B00111110,
B00111110,
B00011100,
B00001000,
B00000000
};
void show( byte * image, unsigned long duration) {
unsigned long start = millis();
while (start + duration > millis()) {
for (int row = 0; row < 8; row++) {
digitalWrite(rowPins[row], ROW_ON);
for (int column = 0; column < 8; column++) {
boolean pixel = bitRead(image[row], column);
if (pixel == 1) {
digitalWrite(columnPins[column], COL_ON); // make the circuit
}
delayMicroseconds(300);
digitalWrite(columnPins[column], !COL_ON);
}
digitalWrite(rowPins[row], !ROW_ON);
}
}
}
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(rowPins[i], OUTPUT);
pinMode(columnPins[i], OUTPUT);
digitalWrite(columnPins[i], LOW);
}
}
void loop() {
show(smallHeart, 80);
show(bigHeart, 160);
delay(800);
}