1
2const int row[8] = {
3 2, 7, 19, 5, 13, 18, 12, 16
4};
5
6
7const int col[8] = {
8 6, 11, 10, 3, 17, 4, 8, 9
9};
10
11
12int pixels[8][8];
13
14typedef bool charMapType[8][8];
15
16const charMapType heart = {
17 {0, 0, 0, 0, 0, 0, 0, 0},
18 {0, 1, 1, 0, 0, 1, 1, 0},
19 {1, 1, 1, 1, 1, 1, 1, 1},
20 {1, 1, 1, 1, 1, 1, 1, 1},
21 {0, 1, 1, 1, 1, 1, 1, 0},
22 {0, 0, 1, 1, 1, 1, 0, 0},
23 {0, 0, 0, 1, 1, 0, 0, 0},
24 {0, 0, 0, 0, 0, 0, 0, 0}
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
51void setup() {
52 for (int thisPin = 0; thisPin < 8; thisPin++) {
53 pinMode(col[thisPin], OUTPUT);
54 pinMode(row[thisPin], OUTPUT);
55 }
56 setupMatrix();
57}
58
59void loop() {
60 displayLedPattern();
61}
62
63void displayLedPattern(){
64 for (int thisRow = 0; thisRow < 8; thisRow++) {
65 digitalWrite(row[thisRow], HIGH);
66 for (int thisCol = 0; thisCol < 8; thisCol++) {
67
68 int thisPixel = pixels[thisRow][thisCol];
69
70
71 digitalWrite(col[thisCol], thisPixel);
72
73 if (thisPixel == LOW) {
74 digitalWrite(col[thisCol], HIGH);
75 }
76 }
77
78 digitalWrite(row[thisRow], LOW);
79 }
80}
81
82void setupMatrix(){
83 for (int x = 0; x < 8; x++) {
84 for (int y = 0; y < 8; y++) {
85 bool v = squares[x][y];
86 if(v){
87 pixels[x][y] = LOW;
88 }else{
89 pixels[x][y] = HIGH;
90 }
91 }
92 }
93}