Page 1 of 1
LED Flashing Delay
Posted: Mon Oct 31, 2011 11:46 pm
by driftlogic
In a complex LED flashing pattern where the delay between LED outputs is determined by a variable called 'rate' how can I instantaneously change the rate value without relying on a macro to do it. For example, Say I have a switch, and depending on the switch state a certain value to 'rate' is set. How can I utilize an interrupt that can read the change in the switch and set the rate value so the change in flashing seems instantaneous?
Thanks.
Re: LED Flashing Delay
Posted: Tue Nov 01, 2011 10:59 am
by Benj
Hello,
You could use say the port interrupt which is basically an interrupt on change for some of the port B pins (normally the upper 4 bits of the port). Then if any of the switches change state you will get an interrupt which can be used to read in the switches and update the delay variable. Some devices allow for interrupt on change for all of port B and some even support multiple ports depending on how many switch inputs you need to the interrupt.
Re: LED Flashing Delay
Posted: Wed Nov 02, 2011 12:45 am
by driftlogic
thank you for the response Ben. i am using a pic16f873a. I'm having a little trouble achieving this based on your suggestion, do know if there are any example files that may help me?
Best,
DriftLogic
Re: LED Flashing Delay
Posted: Wed Nov 02, 2011 11:26 am
by Benj
Hello,
Here is a basic example.