Devices & Components
Arduino Uno Rev3
UTSOURCE Electronic Parts
Project description
Code
Code snippet #1
text
1const int nixie_0 = 2; 2const int nixie_1 = 3; 3const int nixie_2 = 4; 4const int nixie_3 = 5; 5const int nixie_4 = 6; 6const int nixie_5 = 7; 7const int nixie_6 = 8; 8const int nixie_7 = 9; 9const int nixie_8 = 10; 10const int nixie_9 = 11; 11 12const int row_1 = 0; 13const int row_2 = 1; 14 15const int time_on = 3; 16 17void setup() { 18 pinMode(nixie_0, OUTPUT); 19 pinMode(nixie_1, OUTPUT); 20 pinMode(nixie_2, OUTPUT); 21 pinMode(nixie_3, OUTPUT); 22 pinMode(nixie_4, OUTPUT); 23 pinMode(nixie_5, OUTPUT); 24 pinMode(nixie_6, OUTPUT); 25 pinMode(nixie_7, OUTPUT); 26 pinMode(nixie_8, OUTPUT); 27 pinMode(nixie_9, OUTPUT); 28 pinMode(row_1, OUTPUT); 29 pinMode(row_2, OUTPUT); 30 //Serial.begin(9600); //should NOT use seiral println, it will effect to output pin D0 & D1 31} 32 33void loop() { 34 for (int i=0; i<=59; i++){ 35 int j = i/10; //second number from right 36 int k = i%10; //first number from right 37 38 for (int m=0; m<=50; m++){ //this for loop is used for delay showing two numbers 39 //-----------show first number 40 off_all(); 41 on_number(1,k+2); 42 delay(time_on); 43 44 //-----------show second number 45 off_all(); 46 on_number(0,j+2); 47 delay(time_on); 48 } 49 } 50} 51 52void on_number(int row, int nixie){ 53 //void off_all(); 54 digitalWrite(row, HIGH); 55 digitalWrite(nixie, HIGH); 56} 57 58void off_all(){ 59 digitalWrite(nixie_0, LOW); 60 digitalWrite(nixie_1, LOW); 61 digitalWrite(nixie_2, LOW); 62 digitalWrite(nixie_3, LOW); 63 digitalWrite(nixie_4, LOW); 64 digitalWrite(nixie_5, LOW); 65 digitalWrite(nixie_6, LOW); 66 digitalWrite(nixie_7, LOW); 67 digitalWrite(nixie_8, LOW); 68 digitalWrite(nixie_9, LOW); 69 digitalWrite(row_1, LOW); 70 digitalWrite(row_2, LOW); 71 delayMicroseconds(420); //to prevent "ghost" effect to other tube 72}-------------------------------------------------------------------
Comments
Only logged in users can leave comments