Reading the status of a digital pin

Hi, I have just started to mess around with arduino and I am making a little project in which the player needs to press a button if a LED is on. I've been looking around in many tutorials on the Internet but I've found nothing yet. Is there any way to check if a pin is high or low? Thaks a lot.

http://arduino.cc/en/Reference/DigitalRead

nero9885:
I've been looking around in many tutorials

Your research skills want some improvement.

Oops, I think I missed this site xD Thanks a lot, this is what I was looking for... Sorry for my noobness :cold_sweat:

Note a common blunder in tutorials. Because they think "newbies" cannot handle any complication, they frequently describe pushbuttons - or switches or other input devices, as being connected from the input pin to 5V (Vcc) and a pull-down resistor from the input pin to ground to do just that - pull the voltage reliably down to ground when the button is not pressed.

However straightforward and intuitive this may sound, it is terrible engineering practice. Good engineering practice focuses on safety and reliability and running your power line to every external attachment represents a small but unnecessary risk that this line will be shorted to ground resulting not only in improper operation, but a substantial risk of all sorts of damage were that to happen.

Good engineering practice is that you connect the button or switch from the input to ground and use a pull-up to 5V. In fact, since internal pull-ups (mentioned in reference pages) are built into the chip (in most cases), it is all the more practical to use them and not need another resistor. This means that the input reads LOW when the button or switch is closed, but it is no trouble to write your code to suit.

Correspondingly, where you have a LED at any distance from your control box, it is a good idea to have it connected to ground and have its current limiting resistor (or other mechanism) at the control box where it is switched to Vcc, again to limit the consequence of the wiring developing a short circuit.

Good engineering practice focuses on safety and reliability

Good point, Paul. I'll add this to my "What Can Go Wrong" section of classes etc.