pin state

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!

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


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.