Use Of TimerOne

I made it!

I couldn't use the timer on the loop.
I had to do as the first elsabz told about making an owne FunctionName. I dident understand the importens of that....

I have struggled a while, so now I am very happy thank you everyone!!!

:smiley:

// TimerOne - Version: Latest
#include <TimerOne.h>
const int ledPin = 3;

int buttonState = 0;
const int buttonPin = 2;

//timer1 will interrupt at 1Hz
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(ledPin, OUTPUT);

pinMode(buttonPin, INPUT);

Timer1.initialize( 10000000 ); // 10 sek //period in microseconds to call Your function
Timer1.attachInterrupt( FunctionName );

}
// the loop function runs over and over again forever
void loop() {
buttonState = digitalRead(buttonPin);
digitalWrite(ledPin, LOW);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);

}
}

void FunctionName() {
buttonState = digitalRead(buttonPin);
digitalWrite(LED_BUILTIN, LOW);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(LED_BUILTIN, HIGH);

}
}