Poojagaikwad2401 / arduino-timerone

Automatically exported from code.google.com/p/arduino-timerone
0 stars 0 forks source link

start() doesn't appear to work on Uno or Nano #14

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
// This code should flash the LED every second.
// However the start() function doesnt seem to work
// But resume() does.
// But resume doesn't reset the counter, hence its not possible to restart the 
counter from the beginning (time 0)

#include <TimerOne.h>

 int state=0;

void setup() 
{

  pinMode(13, OUTPUT);    

  Timer1.initialize(1000000); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
  Timer1.attachInterrupt( timerIsr ); // attach the service routine here
  Timer1.stop();
  Timer1.start();
//Timer1.resume(); 
}

void loop()
{
  // Main code loop
  // TODO: Put your regular (non-ISR) logic here
}

/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
    state=state^1;
    digitalWrite( 13, state );
}

Original issue reported on code.google.com by synergie7@gmail.com on 28 Nov 2013 at 1:24

GoogleCodeExporter commented 8 years ago
I have found that restart also does not work

Original comment by neal.gal...@socprep.com on 7 Nov 2014 at 5:33