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.
LED Flashing Delay
-
- Posts: 5
- Joined: Thu Oct 13, 2011 5:58 am
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: LED Flashing Delay
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 5
- Joined: Thu Oct 13, 2011 5:58 am
- Contact:
Re: LED Flashing Delay
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
Best,
DriftLogic
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: LED Flashing Delay
Hello,
Here is a basic example.
Here is a basic example.
- Attachments
-
- IOC.fcf
- (7 KiB) Downloaded 480 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel