Buttons and integers


#1

This is a technique question.
I have 16 dashboard switches, 1…16
Each switch represents a number on the dashboard, 1…16
What is the best way to assign an integer (1…16) to a variable based on the switch pushed?
Example :
If I push switch 12, then I want my Index_Integer = 12

I was considering using a CASE statement. But that seems like lots of code just to assign an integer to my index variable.
Thanks for the help.


#2

Solution :
I built a dynamic array using the switch devices as an index. It works perfectly.


#3

I’m not sure of your application.

I’ve used a virtual dimmer to represent 20 presets for my Ir lighting controller. Each value 1 to 20 causes a scene command to be sent via the logitec harmony. You have to code for invalid levels i.e greater than 20. Also the switch can be fiddly to set accurately, but its easy to use via a voice assistant e.g alexa, set light to 2% - sets scene 2 etc