-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with delay() #23
Comments
It would be possible to run the update function on an interrupt rather than through the loop() function. I have not included this in the library because the timers available to set up interrupts are different on each micro-controller, so it gets complicated fairly quickly when considering all possible devices. You could set up a timer-driven interrupt that repeatedly runs refreshDislay() in the background. If you do this, make sure to configure the library to NOT use delays. |
@DeanIsMe Could you please elaborate a bit on this? Maybe an example? |
You need to set up a regular timed interrupt, running @ at least 500Hz (every 2 ms or less). Here's an Instructable for the arduino Uno: https://www.instructables.com/Arduino-Timer-Interrupts/ |
@MehdiGol @SlevenCalevra something to try... you can use a PWM output as a nearly 500Hz clock (one of the PWMs is 490Hz by default on some Arduinos, and others get you close or better, I think). Plug a 1k resistor from the PWM output to a digital input and setup the digital input to interrupt on the rising edge. Create a function that calls the |
@mbratch not to be offensive or anything but that's a really roundabout way of doing this. I'd sudgest looking into timer interrupts or other kinds of internal interrupts. |
@machmar meh, no offense taken. That was 2 years ago. A fun little idea I had on my breadboard when I first got my Arduino before I determined how to tap into the timer interrupts. A little round-about but it was very easy to do. I certainly wasn't touting it as the best approach (I had prefaced my suggestion as "something you can try...") |
Hi,
is there no way to use this correctly when you have delays in your program???
The text was updated successfully, but these errors were encountered: