-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Nixie-Tube-Driver-Example-1.ino
62 lines (52 loc) · 1.68 KB
/
Nixie-Tube-Driver-Example-1.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
// Nixie Tube Driver by Marcin Saj https://nixietester.com
// https://github.com/marcinsaj/Nixie-Tube-Driver
//
// Driving Nixie Tube Example #1
//
// This example demonstrates how to control a nixie tube.
// The control is carried out using the Nixie Tube Driver.
#define DIN_PIN 7 // Nixie driver (shift register) serial data input pin
#define CLK_PIN 6 // Nixie driver clock input pin
#define EN_PIN 5 // Nixie driver enable input pin
void setup()
{
pinMode(DIN_PIN, OUTPUT);
digitalWrite(DIN_PIN, LOW);
pinMode(CLK_PIN, OUTPUT);
digitalWrite(CLK_PIN, LOW);
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW);
}
void loop ()
{
for(int i = 0; i <= 9; i++)
{
NixieDisplay(i); // Do simple counting
delay(1000);
}
}
void NixieDisplay(byte digit)
{
// Ground EN pin and hold low for as long as you are transmitting
digitalWrite(EN_PIN, 0);
// Clear everything out just in case to
// prepare shift register for bit shifting
digitalWrite(DIN_PIN, 0);
digitalWrite(CLK_PIN, 0);
// Send data to the nixie driver
for (int i = 15; i >= 0; i--)
{
// Set high only the bit that corresponds to the current nixie cathode
if(i == digit) digitalWrite(DIN_PIN, 1);
else digitalWrite(DIN_PIN, 0);
// Register shifts bits on upstroke of CLK pin
digitalWrite(CLK_PIN, 1);
//Set low the data pin after shift to prevent bleed through
digitalWrite(CLK_PIN, 0);
}
// Return the EN pin high to signal chip that it
// no longer needs to listen for data
digitalWrite(EN_PIN, 1);
// Stop shifting
digitalWrite(CLK_PIN, 0);
}