Put a nixie tube display to show the frequency of the old 1940's

I want to place a frequency display on an old radio. I saw a beautiful design with nixie tubes on YouTube. I had to retype the software from the video. I can't get in touch with the designer. The oscillator signal is presented on A5 of the Arduino. (after dividing by 8 with a CD4040) The pulses come in nicely. But the counter keeps running, which is not the intention. Counting must take place within a certain time window. The operation of counting is made clear by the LED of pin 13. This LED does not light up. I just can't find the error. Please some help. Marc ON4DM

Also here the schematic as seen on youtube. I connected A5 of the UNO to pin 6 of the CD4040 (16 divider). I also designed the input of the CD4040 (pin10) differently. I connected a frequency generator of 1 kHz to the CD4040. I have not connected any Nixie tubes yet. Is not important for testing the software. Marc

typ of plak hier code
// NIXIE DISPLAY RADIO
// put a nixie tube display to show the frequency of the old 1940's
// radio.
// DESIGN: GLASSLINGER (YOUTUBE)
// 06/03/2019
// ( https://www.youtube.com/watch?v=mvCwzLowmOo&t=2365s )
// COPIED BY ON4DM
// 29/03/2024

//*******************************************************************
//*******************************************************************

int led = 13;
int count;//input pulses on A5 in 100ms
int freq;//received frequency
int locosc;//local oscillator
int ones, tens, hunds, ovfl = 0;
int n;//junk variable

void process(int);//take countand output

void setup()
{ Serial.begin(9600);
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(led, OUTPUT);
pinMode(A5, INPUT);//input pulse

//******* initialize timer 1 *********

noInterrupts();//ints off during setup

TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 8020;//dick with this number to adjust freq
TCCR1B |= (1 << WGM12);//CTC MODE
TIMSK1 |= (1 << OCIE1A);//ENABLE TIMER ON
interrupts();//all ints on
}

//******* interrupt handling *******

ISR(TIMER1_COMPA_vect)
{
digitalWrite(led, digitalRead(led) ^ 1);
locosc = count;//save current count
count = 0;//start new count
process(locosc);
}

//******* code to increment the frequency count *******

void loop()
{ //Serial.println("hello");
n = digitalRead(A5);//read the state of the input pin A5
if (n == 1)
count ++;//count the pulses
while (n == 1)//wait for input pin to go low
n = digitalRead(A5);
//Serial.println(count);
}

//******* code to change the binary count to BCD *******

void process(int)
{
freq = locosc - 455;//loc osc - IF
hunds = 0;
tens = 0;
ones = 0;
ovfl = 0;
//do the overflow 1
if (freq > 1000)
ovfl = 1;//set top digit, freq over 1
hunds = freq % 1000;//get rid of counts
tens = hunds % 100;//get rid of counts
ones = tens % 10;//this directly the hunds
hunds = hunds - tens;//this strips the thens
hunds = hunds / 100;//convert to digit
tens = tens - ones;//this strips the ones
tens = tens / 10;//convert to digit

// output the digit nibbles to the port pins
// reads the bit from the digit
// countand output the bit
// to the UNO pin

digitalWrite(0, bitRead(ones, 0));
digitalWrite(1, bitRead(ones, 1));
digitalWrite(2, bitRead(ones, 2));
digitalWrite(3, bitRead(ones, 3));
digitalWrite(4, bitRead(tens, 0));
digitalWrite(5, bitRead(tens, 1));
digitalWrite(6, bitRead(tens, 2));
digitalWrite(7, bitRead(tens, 3));
digitalWrite(8, bitRead(hunds, 0));
digitalWrite(9, bitRead(hunds, 1));
digitalWrite(10, bitRead(hunds, 2));
digitalWrite(11, bitRead(hunds, 3));
digitalWrite(12, bitRead(ovfl, 0));

}```

Please edit your post to add code tags, and post a schematic. Hand drawn is preferred, with all pins and connections clearly labeled.

Please edit your original post to add code tags. For instructions, see the "How to get the best out of this forum" post.

You cannot use pins 0 and 1 for digital I/O on the Uno or other ATmega Arduinos, if you also use Serial and/or the bootloader.

Those pins are reserved for program upload via the bootloader and for serial debugging.

Then that is in error! The window code should turn off interrupts, grab and store the count and reset it. Then turn the interrupts back on. Use the save count value in the calculation. So much easier!

I will be honest. My knowledge of programming is very basic. If possible, show which program lines I need to change. Thanks in advance.

Nothing to do with your programming, It your concept of how to do what you want is wrong.

first of all any variables that are used and modified within the ISR and are used outside of the ISR need to be declared 'volatile' so that the version of the variable that is in the actual memory address is used and not the one that was read into a register.

volatile int count;//input pulses on A5 in 100ms
volatile int locosc;//local oscillator

secondly, if you use 16 bit variables that can be modified inside the ISR and read or modify them outside of the ISR, you need to turn interrupts 'off' while you do so, or you run the risk of part of the variable changing while you are busy with it.

noInterrupts();
freq = locosc - 455;//loc osc - IF
interrupts();

and

noInterrupts();
count ++;//count the pulses
interrupts();

For the rest we will need more info.

You are somehow using a timer interrupt, maybe you did not set it up properly. You could use the TimerOne library instead, it is more user friendly and does not require you to set up the registers yourself.