Hello,
I'm working on a project that shows three LED Array patterns depending on which button you push (one pattern per button for the Switchbank). The pattern should change each time you push a different button. I am able to show the correct pattern for the corresponding button when I first push a button. When I try to push another button, the pattern doesn't change to a new one. Basically, the state of the switchbank is retained (1 if you push the right most; 2 if you push the middle, 4 is you push the last on the left) and doesn't change even when you push another one. I think the key is to get out of the loop for the pattern so that the program lets you push another button and display a new pattern. I just don't know how to do that or where to go next. The variable I set for this is 'push'.
Also, when the pattern is running and you push another button, the new pattern must start at the LED where the button was pushed and the pattern was interrupted (say a new button was pushed and the pattern was interrupted at LED5, the new pattern must start at LED5). The variable I used for the LED Array is 'led'.
Can you guys help me, please?
--choy
Controlling LED Patterns using Switchbank
Controlling LED Patterns using Switchbank
- Attachments
-
- ledarray-011812-all.fcf
- (17.5 KiB) Downloaded 245 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Controlling LED Patterns using Switchbank
Hello choy,
You could give this a try.
I was running a bit late so I rushed it a bit, but hopefully it will work.
This is the non port B interrupt version. Reason why it did not work is because after switch component was a loop which altered state of LED's.
But the loop could not be exited until push value changed.
However push can't changed because there was not an input assigned to push placed inside any of the loops.
Not tested on hardware.
With the port B interrupt version you could would need less changing but you will need switches connected an ports B4 to B7 e.g B4,B5 & B6
I can post that version tomorrow if your interested?
Martin
You could give this a try.
I was running a bit late so I rushed it a bit, but hopefully it will work.
This is the non port B interrupt version. Reason why it did not work is because after switch component was a loop which altered state of LED's.
But the loop could not be exited until push value changed.
However push can't changed because there was not an input assigned to push placed inside any of the loops.
Not tested on hardware.
With the port B interrupt version you could would need less changing but you will need switches connected an ports B4 to B7 e.g B4,B5 & B6
I can post that version tomorrow if your interested?
Martin
- Attachments
-
- ledarray-011812-all Rev2.fcf
- (15.02 KiB) Downloaded 262 times
Martin
Re: Controlling LED Patterns using Switchbank
Hey martin,
Thanks for the reply. This was the first thing I checked as soon as I woke up today.
Thank you for your help! Yes I'd like to see the port B interrupt version.
Thanks for the reply. This was the first thing I checked as soon as I woke up today.
Thank you for your help! Yes I'd like to see the port B interrupt version.

Re: Controlling LED Patterns using Switchbank
Martin,
Can you also tell me what the variables First_time and Read_portB are for?
Thanks again!
Can you also tell me what the variables First_time and Read_portB are for?
Thanks again!

-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Controlling LED Patterns using Switchbank
Attached is one way way of placing input within each loop so its nearer to your original version
If there is a something your not sure of:
First set Key mappings up for the switches (searching this forum will help for that)
Then remove the variable you want to find out about.
Finally press a key that switch is mapped to, and single step by pressing F8.
Observe what the difference is.
If you still are unsure, let me know and will post the answer.
If there is a something your not sure of:
First set Key mappings up for the switches (searching this forum will help for that)
Then remove the variable you want to find out about.
Finally press a key that switch is mapped to, and single step by pressing F8.
Observe what the difference is.
If you still are unsure, let me know and will post the answer.
- Attachments
-
- ledarray-011812-all Rev3.fcf
- (14.96 KiB) Downloaded 268 times
Martin
Re: Controlling LED Patterns using Switchbank
Hey Martin,
Again, I want to thank you for helping me out. I was finally able to figure it out. I used three variables in this program -- led, push and hold_push. Your idea about using Read_PortB variable for the push button input instead of using the push variable (which in turn was used for cases 1, 2 and 4) was the key to solving my issue. Also, I added a condition that tells the program to set the led variable to 1 and 128 under case 1 and case 2 respectively if the program is run initially so that the led array displays the pattern from which LED position the pattern was interrupted. Everything works as desired. Thank you!
Again, I want to thank you for helping me out. I was finally able to figure it out. I used three variables in this program -- led, push and hold_push. Your idea about using Read_PortB variable for the push button input instead of using the push variable (which in turn was used for cases 1, 2 and 4) was the key to solving my issue. Also, I added a condition that tells the program to set the led variable to 1 and 128 under case 1 and case 2 respectively if the program is run initially so that the led array displays the pattern from which LED position the pattern was interrupted. Everything works as desired. Thank you!
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Controlling LED Patterns using Switchbank
That's great choy,
I'm glad you have got it all worked out now.
Glad I could help.
Martin
I'm glad you have got it all worked out now.
Glad I could help.
Martin
Martin