Go Down

Topic: pin state (Read 232 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