Timer 1 not work in simple program

I wrote a simple program for Timer 1 but did not work and responded quickly.
What is the reason for not working Timer 1 in a simple program?
i use TimerOne library

#include <TimerOne.h>

//after get card (switch is on)delay 1 second and turn on led
volatile int card_in_key = 6 ;
const boolean card_in = 1 ;
boolean t1_flag = 0;

void setup()

pinMode(card_in_key,INPUT_PULLUP); // add pullup after not work timer
Timer1.initialize(1000000); // 1 s
Timer1.attachInterrupt(delay_time); //


void loop() {
while ( digitalRead(card_in_key)== card_in )
delayMicroseconds(50); // add after
if (t1_flag == 0 )
Timer1.restart(); // restart and start not work
t1_flag = 1;
//my other code
delay(100); // delay ms added after the timer 1 not work
digitalWrite(7 , HIGH );
t1_flag = 0 ;

void delay_time(){

t1_flag = 1;
digitalWrite(7 , LOW ) ;

Please indent your code and post with code tags. This is a mess t read but noticed t1_flag was not volatile. Won't read the rest until it's cleaned up

@vahidjan, please do not cross-post. Threads merged.

It gets inside the interrupts , but The answer was quick

Your logic looks faulty to me.

After one second and the interrupt is triggered the timer is stopped and the flag is set to 1.

Then, with INPUT_PULLUP on pin 6 you will stay in the while loop where the if conditional to restart the timer is flag==0. I don't see how anything is going to proceed.

If pin 6 is taken to ground and you break from the while loop, you call timer.stop() again.

When interrupt was pin6 = 1 starts .
interrupts timer is required when pin6 = 1. The LED turns on and off when pin6 is high and low but not delayed (1s) and fast on or off . If interrupts did not work , the LED would not work