-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBCD_Display.ino
104 lines (87 loc) · 2.21 KB
/
BCD_Display.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
// 1-digit BCD Counter - by Bill Jenkins 07-17-2018
// This sketch simulates a one digit BCD counter
// with the clock time set by parameter
// define variables for BCD output, d = high order bit, a = low order bit
int BCDd = 11; // high order bit
int BCDc = 10;
int BCDb = 9;
int BCDa = 8; // low order bit
int CYCLE = 1000; // delay time in milliseconds
int i = 0; // test for start
void setup() { // initialize output pins
pinMode(BCDd, OUTPUT);
pinMode(BCDc, OUTPUT);
pinMode(BCDb, OUTPUT);
pinMode(BCDa, OUTPUT);
}
void loop() {
//light all four LEDs to indicate sequence start
if (i==0){
digitalWrite(BCDd, HIGH);
digitalWrite(BCDc, HIGH);
digitalWrite(BCDb, HIGH);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
i++;
}
// write a BCD '0'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, LOW);
delay(CYCLE);
// write a BCD '1'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
// write a BCD '2'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, HIGH);
digitalWrite(BCDa, LOW);
delay(CYCLE);
// write a BCD '3'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, HIGH);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
// write a BCD '4'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, HIGH);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, LOW);
delay(CYCLE);
// write a BCD '5'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, HIGH);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
// write a BCD '6'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, HIGH);
digitalWrite(BCDb, HIGH);
digitalWrite(BCDa, LOW);
delay(CYCLE);
// write a BCD '7'
digitalWrite(BCDd, LOW);
digitalWrite(BCDc, HIGH);
digitalWrite(BCDb, HIGH);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
// write a BCD '8'
digitalWrite(BCDd, HIGH);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, LOW);
delay(CYCLE);
// write a BCD '9'
digitalWrite(BCDd, HIGH);
digitalWrite(BCDc, LOW);
digitalWrite(BCDb, LOW);
digitalWrite(BCDa, HIGH);
delay(CYCLE);
}