Skip to main content
added 106 characters in body
Source Link
Majenko
  • 105.9k
  • 5
  • 82
  • 139

I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.

#include “TimerOne.h”
bool val=0;
void setup()
{
    pinMode(13, OUTPUT);
    Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
    Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
}

void callback()
{
    val=1;
}

void loop()
{
    digitalWrite(13,val);
    while(!val);
    val=0;
}

#include “TimerOne.h” bool val=0; void setup() { pinMode(13, OUTPUT); Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt } void callback() { val=1; } void loop() { digitalWrite(13,val); while(!val); val=0; } TheThe LED doesnt blink at all! Any help would be appreceitated! thanks!

I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.

#include “TimerOne.h” bool val=0; void setup() { pinMode(13, OUTPUT); Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt } void callback() { val=1; } void loop() { digitalWrite(13,val); while(!val); val=0; } The LED doesnt blink at all! Any help would be appreceitated! thanks!

I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.

#include “TimerOne.h”
bool val=0;
void setup()
{
    pinMode(13, OUTPUT);
    Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
    Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
}

void callback()
{
    val=1;
}

void loop()
{
    digitalWrite(13,val);
    while(!val);
    val=0;
}

The LED doesnt blink at all! Any help would be appreceitated! thanks!

Source Link

How to resolve my Timer Interrupt issue

I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.

#include “TimerOne.h” bool val=0; void setup() { pinMode(13, OUTPUT); Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt } void callback() { val=1; } void loop() { digitalWrite(13,val); while(!val); val=0; } The LED doesnt blink at all! Any help would be appreceitated! thanks!