Skip to content

Arduino Uno readDigital equivalent #511

Answered by Rahix
jbugalho asked this question in Q&A
Discussion options

You must be logged in to vote

(Converted this to a discussion)

 let button = pins.d9; // i think the default is input (?)

Yes, default is input. Actually, you can only call the methods for input pins when the pin is configured as input, so you can't accidentally do the wrong thing here :)

For some reason this code is always lighting the green led!

Well, that's exactly what you wrote in your code? While the button is not pressed, it will continuously loop over setting the green LED pin high and then checking whether the button pin is high.

Maybe what you mean is that pressing the button doesn't do anything? If yes, that has to be an electrical issue. How did you connect the button?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jbugalho
Comment options

Answer selected by jbugalho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #510 on March 01, 2024 16:12.