04-05-2023 08:17 PM
Let's just suppose you want to control 5 led indicators using two buttons "left" and "right" just like the screenshot that I have uploaded. You want the middle one to be light up at first then for example if you press right button, then the middle one just goes off and the right next to it, lights up. Preferably, key binding each of the buttons to the right and left arrow on the keyboard. How would you do that?
Solved! Go to Solution.
04-05-2023 08:46 PM
You need a event driver state machine to do such thing.
04-06-2023 02:57 AM
@Seiryuu90 wrote:
Let's just suppose you want to control 5 led indicators using two buttons "left" and "right" just like the screenshot that I have uploaded. You want the middle one to be light up at first then for example if you press right button, then the middle one just goes off and the right next to it, lights up. Preferably, key binding each of the buttons to the right and left arrow on the keyboard. How would you do that?
The easiest is to change your LEDs to an array of LEDs. Initialized it to 00100, then use either a timed loop or event structure and Rotate array when one of the buttons are pressed. How to bind a key to the button? Button Properties.
04-06-2023 04:34 AM - edited 04-06-2023 04:47 AM
@santo_13 wrote:
- Based on the button changed, do a logical shift (right or left) on the array and display the values using the LEDs
How do I do that?
If you could make sample, would be grateful please.
Also, why does auto indexing an array inside a while loop gives me error but a for loop does not? How to fix it
?
04-06-2023 05:06 AM
You can resolve this by this way :
Loïc.
04-06-2023 11:08 AM
Few Modifications
1. 3rd element is True by default
2. The order of Cluster is changed to avoid array reversing and readability
3.You can use -1 instead of Rotate 1D array to Left Shift.
4. Also, I guess it should limit Movement once it reaches its extreme right/left
04-06-2023 01:30 PM
It is very nice of you guys to do the homework for the OP. Unfortunately, they will not learn LV that way. 😁
04-06-2023 02:19 PM
Trust me I'm learning just fine thank you for your concern. Goodnight.
04-06-2023 02:34 PM - edited 04-06-2023 03:34 PM
Thank you and Loic much for your help.