Hi, I have been working through your web site and the Book Build Web Servers trying to combine the Websocket tutorial and add physical buttons to this. The other tutorials on your web page that have buttons are either arduino IDE or non web socket or are so different in their layout that and I just cant seem to figure out where to add this extra code in. Is there anywhere else that has examples of this or can you point me in the right direction? Thankyou.
Adding physical buttons is even simpler with WebSocket than with the other methods we have on our website.
For example, let’s take a look at example 2.5 and see how we can add that part.
1) Add the code that detects the button presses in the loop.
2) Whenever a button is pressed, invert the corresponding current output state.
3) Call the notifyClients() function and pass as argument the getOutputStates() function to inform all clients of the new states of your outputs.
I hope this helps.