Hey guys,
Im just trying to use timer1 to call a function.
Here is my code:
#include <TimerOne.h>
void setup() {
pinMode(9, OUTPUT);
Timer1.initialize();
Timer1.attachInterrupt(pwm, 5000000);
}
void loop(){
digitalWrite(13,HIGH);
}
void pwm(){
digitalWrite(9, HIGH);
delay(250);
digitalWrite(9,LOW);
delay(250);
digitalWrite(9, HIGH);
delay(250);
digitalWrite(9,LOW);
delay(250);digitalWrite(9, HIGH);
delay(250);
digitalWrite(9,LOW);
delay(250);
}
Basically I am trying to blink an LED at 1/4 second intervals, 3 times, every 5 seconds. I am doing this to try and work out how to use Timer1. At the moment my LED will blink every 5 seconds (as hoped), but will only turn on once and only for a very short period of time. When I change the sketch so that the LED should only blink once and stay on for one second, the LED does not do this and blinks for that same short period of time.
What's wrong with my code?
Thanks for your help!