Go Down

Topic: pin state (Read 246 times) previous topic - next topic

wmassano

Is there a way of detecting a pin's current state (high or low)? I need something which doesn't depend on knowing the history of the pin. I am thinking of something like bitread from one of the ports, but am not sure how it would be implemented. It should work on a general arduino (leonardo, uno, mega, etc), but I'll start with an uno. Thanks!

billroy

digitalRead(pin) will tell you the state an output pin is set to.

-br

wmassano

Thanks, I thought you had to have the pin set to input mode to do a digital read from it or the compiler would give an error. That is why I asked. I should have tried it first. Again, thanks.
                                       WM

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy