TimerOne Interupt Problem

Hello, i am using the TimerOne library for an interupt. I wrote first a simple programm to see if interupt workes fine.

The led doesnt work, like the programm never go out of the interupt. Any idea?

Something like the RET on assembly, to go out of the interupt and also reset timer and flag

#include <TimerOne.h>


int led_dokimi = 13;

void setup()
{
  
  pinMode(led_dokimi, OUTPUT);
   digitalWrite(led_dokimi, HIGH);
  Timer1.initialize(1500000); // 1.5 sec
  Timer1.attachInterrupt(blinkLED);
}



void loop()
{
  // program here..
}


void blinkLED(void)
{
  if (led_dokimi == LOW) 
 {
    led_dokimi = HIGH;
   } else 
{
    led_dokimi = LOW;
 }
  
}

Look carefully at your program.
Which part of your code turns the LED on and off ?

    led_dokimi = HIGH;

will set the led_dokimi variable to 1. Will that turn the LED on ?

Incidentally
led_dokimi = !led_dokimi;would change the variable from HIGH to LOW or vice-versa in the ISR. It would still not turn the LED on or off though....

You need to separate the led's pin number, 13, from its state (HIGH or LOW) in your
code. Without digitalWrite() your cannot affect the pin.

Ouh, yes that was mistake cause wrote it fast. It works now so i guess library makes 0 the flag and return be its own.

Thanks, mates :slight_smile:

It works now so i guess library makes 0 the flag and return be its own.

I am glad that it works but I have no idea what you mean.

Im new to Arduino and its code. On assembly when you call an inerupt you make 0 the overflow flag of timer and with RET command you leave interupt to go back.

That timerOne library dunno how its working

On assembly when you call an inerupt you make 0 the overflow flag of timer and with RET command you leave interupt to go back.

I have no idea what that means either, sorry. Let's just settle for the fact that your program works now and move on.