-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex20.ino
60 lines (58 loc) · 1.92 KB
/
ex20.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
const int row1 = 2;// the number of the row pin 9
const int row2 = 3; // the number of the row pin 14
const int row3 = 4; // the number of the row pin
const int row4 = 5; // the number of the row pin 12
const int row5 = 17; // the number of the row pin 1
const int row6 = 16; // the number of the row pin 7
const int row7 = 15; // the number of the row pin 2
const int row8 = 14; // the number of the row pin 5
// The pin to control COl
const int col1 = 6; // the number of the col pin 13
const int col2 = 7; // the number of the col pin 3
const int col3 = 8; // the number of the col pin 4
const int col4 = 9; // the number of the col pin 10
const int col5 = 10; // the number of the col pin 6
const int col6 = 11; // the number of the col pin 11
const int col7 = 12; // the number of the col pin 15
const int col8 = 13; // the number of the col pin 16
void setup () {
int i = 0;
for (i = 2; i<18; i++) {
pinMode (i, OUTPUT);
}
pinMode (row5, OUTPUT);
pinMode (row6, OUTPUT);
pinMode (row7, OUTPUT);
pinMode (row8, OUTPUT);
for (i = 2; i <18; i++) {
digitalWrite (i, LOW);
}
digitalWrite (row5, LOW);
digitalWrite (row6, LOW);
digitalWrite (row7, LOW);
digitalWrite (row8, LOW);
}
void loop () {
int i; // The row # 1 and col # 1 of the LEDs turn on
digitalWrite (row1, HIGH);
digitalWrite (row2, LOW);
digitalWrite (row3, LOW);
digitalWrite (row4, LOW);
digitalWrite (row5, LOW);
digitalWrite (row6, LOW);
digitalWrite (row7, LOW);
digitalWrite (row8, LOW);
digitalWrite (col1, LOW);
digitalWrite (col2, HIGH);
digitalWrite (col3, HIGH);
digitalWrite (col4, HIGH);
digitalWrite (col5, HIGH);
digitalWrite (col6, HIGH);
digitalWrite (col7, HIGH);
digitalWrite (col8, HIGH);
delay (1000); // Turn off all
for (i = 2; i <18; i++) {
digitalWrite (i, LOW);
}
delay (1000);
}