Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Great Tutorial. One question about the code #21

Open
budbham opened this issue Jan 30, 2022 · 1 comment
Open

Great Tutorial. One question about the code #21

budbham opened this issue Jan 30, 2022 · 1 comment

Comments

@budbham
Copy link

budbham commented Jan 30, 2022

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.

@Bromiun
Copy link

Bromiun commented Feb 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants