remote-control-with-websocket icon indicating copy to clipboard operation
remote-control-with-websocket copied to clipboard

Great Tutorial. One question about the code

Open budbham opened this issue 3 years ago • 1 comments
trafficstars

I am just getting into working with microprocessors but had C++ class about 25 years ago.

This code example is perfect for a fun project that I am working on.

I am wondering about one piece of code in the button section that I am not quite sure what the C++ code is doing with the == in this context. bool pressed = reading == LOW;

Aside for this, the explanations were great.

If you want to take this example further; it would be interesting to have two buttons with associated LEDs along with a counter that that compares how much one LED has been "ON" verses the other. This could be an interesting game were two people get on the web page and try to have their light "ON" for more than the other person. They would have to alternate between trying to turn "ON" their LED while turning "OFF" the other LED.

budbham avatar Jan 30 '22 20:01 budbham

If we agree that C has lowest precedence for the assignment statement (=), then the code will first check to see if reading is LOW and the result which is true or false is assigned to pressed.

Bromiun avatar Feb 10 '23 00:02 Bromiun