Pages: [1]   Go Down
Author Topic: pin state  (Read 191 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 45
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: