0

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

asked Oct 1, 2018 at 15:27
1
  • Re "the timerOne library [...] just works with a fixed time delay": what makes you believe that? Commented Oct 1, 2018 at 15:45

2 Answers 2

1

https://github.com/PaulStoffregen/TimerOne/blob/master/TimerOne.h#L55

Defines the function in TimerOne called SetPeriod(). That will change the period.

answered Oct 1, 2018 at 15:47
1
  • 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!! Commented Oct 1, 2018 at 23:07
0

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!!

answered Oct 1, 2018 at 23:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.