I have a led strip, and each led should be turned on sequentially, such as this one: [http://1.bp.blogspot.com/-CTT6yvYtdos/VihhhBItwjI/AAAAAAAAAvM/q1jbUylMMdM/s400/ezgif.com-video-to-gif.gif][1] The time delay between 2 consecutive leds is ts, and that time should be adjusted externally through a pushbutton switch. Each time the button is pressed, the time period shoud increment in a fixed amount. I've already used the timerOne library, but it just works with a fixed time delay ts. How can I solve this issue with VARIABLE time delay? I prefer to use interruptions rather than polling, since this system will be more complex (other buttons and variables will be involved). Thanks! Fernando
-
Re “the timerOne library [...] just works with a fixed time delay”: what makes you believe that? – Edgar Bonet Oct 1 '18 at 15:45
https://github.com/PaulStoffregen/TimerOne/blob/master/TimerOne.h#L55
Defines the function in TimerOne called SetPeriod()
. That will change the period.
-
I've found the solution, through the function attachInterrupt(function,period); inside loop() In other words, I wrote loop(){ Timer1.attachInterrupt(function,period); // rest of the code } where period changes inside the ISR called when the external button is pressed. Thanks a lot @jose can u c!! – fmarengo Oct 1 '18 at 23:07
I've found the solution, through the function
attachInterrupt(function,period);
inside
loop()
In other words, I wrote
loop(){
Timer1.attachInterrupt(function,period);
// rest of the code
}
where "period" changes inside the ISR called when the external button is pressed. Thanks a lot @jose can u c!!