-
Notifications
You must be signed in to change notification settings - Fork 0
/
Binary Counter
91 lines (69 loc) · 1.9 KB
/
Binary Counter
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
// Ashley English, 30-Nov-2021 LED Matrix Binary Clock
// Used Mod to turn on columns in steps.
// PROPOSED EDITS: Don't use high or low, only disable and enable;
// set the arduino pins associated with rows and columns
const int MAXLROW = 8;
const int MAXLCOL = 8;
const int lRow[MAXLROW] = {6, 7, 8, 9, 10, 11, 12, 13}; //ASSUMES NORTH (UP) is POSITIVE, origin at bottom
const int lCol[MAXLCOL] = {2, 3, 4, 5, A4, A3, A2, A1} ; //ASSUMES EAST (RIGHT) IS POSITIVE, origin at right
int i;
int t=0;
// define rows, LOW = enabled, HIGH = disabled
// define columns, LOW = disabled, HIGH = enabled
#define ENABLE_LROW LOW
#define ENABLE_LCOL HIGH
#define DISABLE_LROW HIGH
#define DISABLE_LCOL LOW
void setup()
{
// set led matrix row and column pins as OUTPUT
for (i=0; i<MAXLROW; i++)
{
pinMode(lRow[i], OUTPUT);
}
for (i=0; i<MAXLCOL; i++)
{
pinMode(lCol[i], OUTPUT);
}
// initialize the columns to be completely 'OFF' and rows to be completely 'ON'
for (i=0; i<MAXLROW; i++)
{
digitalWrite(lRow[i], ENABLE_LROW);
}
for (i=0; i<MAXLCOL; i++)
{
digitalWrite(lCol[i], DISABLE_LCOL);
}
}
void AllOff()
{
//All columns off. Rows do not need to be turned off given that enabled or disabled makes no difference if column is disabled.
for(i = 0; i<MAXLCOL; i++) digitalWrite(lCol[i], DISABLE_LCOL);
}
void loop() // *** BINARY CLOCK/COUNTER ***
/*
{
t = t + 1;
digitalWrite(lCol[A1], HIGH);
if(t%2 == 1)
digitalWrite(lCol[A2], HIGH);
if(t%4 == 1)
digitalWrite(lCol[A3], HIGH);
if(t%8 == 1)
digitalWrite(lCol[A4], HIGH);
if(t%16 == 1)
digitalWrite(lCol[2], HIGH);
if(t%32 == 1)
digitalWrite(lCol[3], HIGH);
if(t%64 == 1)
digitalWrite(lCol[4], HIGH);
if(t%126 == 1)
digitalWrite(lCol[5], HIGH);
delay(500);
AllOff();
delay(500);
}
*/
{
digitalWrite(lCol[A1], ENABLE_LCOL);
}