Quick newb question, please. I've got code for a project which publishes MQTT strings based on the results of a gesture sensor. Skipping all the setup stuff, the line that does the magic is..
which publishes the payload "up" to the MQTT topic "server1" & works great.
My Issue
I'm planning to have a physical toggle switch on the side of the device and depending on its position, want to to either "server1" or "server2" therefore need to replace "server1" above with a variable like "server" which I can then flipflop to either one. Below is the last failed coding snippet pertaining only to the physical switch, desired variable, and part of code that publishes the topic that will use the variable.