-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNixie_Shield_Simple_Counter_Example_2.ino
116 lines (101 loc) · 3.84 KB
/
Nixie_Shield_Simple_Counter_Example_2.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
105
106
107
108
109
110
111
112
113
114
115
116
/*
Nixie Shield Simple Counter Example 2
This example shows how to make a simple nixie counter.
Functions help keep code organized.
Nixie Shield uses five digital outputs to drive nixie tube.
Pin A0 as on/off line, 13,12,11,10 as an address of nixie tube cathode.
This example code is in the public domain.
http://www.nixietester.com
*/
const int EN = A0; // A0 pin is attached to on/off line
const int A = 13; // 13,12,11,10 pins are attached to address lines
const int B = 12;
const int C = 11;
const int D = 10;
void setup() {
pinMode(EN, OUTPUT); // declare pin A0 as output
pinMode(A, OUTPUT); // declare pins 13,12,11,10 as output
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
nixietubeON(); // Turn on the tube
for(int i = 0; i < 10; i++ ){
nixietube(i); // Display digit 0 to 9
delay (1000);
}
nixietubeOFF(); // Turn off the tube
delay(2000);
}
void nixietube(int digit){ // Nixie Tube Display Function
switch (digit) {
case 0: // ___
digitalWrite(A, LOW); // | |
digitalWrite(B, LOW); // | |
digitalWrite(C, LOW); // | |
digitalWrite(D, LOW); // |___|
break;
case 1:
digitalWrite(A, HIGH); // /|
digitalWrite(B, LOW); // / |
digitalWrite(C, LOW); // |
digitalWrite(D, LOW); // |
break;
case 2: // ___
digitalWrite(A, LOW); // |
digitalWrite(B, HIGH); // ___|
digitalWrite(C, LOW); // |
digitalWrite(D, LOW); // |___
break;
case 3: // ___
digitalWrite(A, HIGH); // |
digitalWrite(B, HIGH); // ___|
digitalWrite(C, LOW); // |
digitalWrite(D, LOW); // ___|
break;
case 4:
digitalWrite(A, LOW); // | |
digitalWrite(B, LOW); // |___|
digitalWrite(C, HIGH); // |
digitalWrite(D, LOW); // |
break;
case 5: // ___
digitalWrite(A, HIGH); // |
digitalWrite(B, LOW); // |___
digitalWrite(C, HIGH); // |
digitalWrite(D, LOW); // ___|
break;
case 6: // ___
digitalWrite(A, LOW); // |
digitalWrite(B, HIGH); // |___
digitalWrite(C, HIGH); // | |
digitalWrite(D, LOW); // |___|
break;
case 7: // ___
digitalWrite(A, HIGH); // |
digitalWrite(B, HIGH); // |
digitalWrite(C, HIGH); // |
digitalWrite(D, LOW); // |
break;
case 8: // ___
digitalWrite(A, LOW); // | |
digitalWrite(B, LOW); // |___|
digitalWrite(C, LOW); // | |
digitalWrite(D, HIGH); // |___|
break;
case 9: // ___
digitalWrite(A, HIGH); // | |
digitalWrite(B, LOW); // |___|
digitalWrite(C, LOW); // |
digitalWrite(D, HIGH); // ___|
break;
}
}
void nixietubeON(){ // Turn on the tube Function
digitalWrite(EN, LOW);
}
void nixietubeOFF(){ // Turn off the tube Function
digitalWrite(EN, HIGH);
}