The digital pin can be taken as INPUT or OUTPUT. PinMode() can be used to change a digital pin into OUTPUT from INPUT.
Pins are configured as Inputs.
Configuring pin Arduino（Atmega） as INPUT through pinMode() is configuring it to a high impedance state.
Te configuration of INPUT to the pins can be understood as the pins have minimal requirements to the circuits when they take samples, which is equal to connect a 100Megohms resistor in series in front of the pins.
This makes them very conducive to read the sensors, rather than supply power to LED.
Configure the pins as Outputs.
Pins can be configured as OUTPUT through pinMode(), that is configure it ast a low impedance state.
It means that they can provide enough current for the circuit. Pin Atmega can provide（provide positive current）or flow backward（provide negative current）other devices/circuits with current which can achieve 40mA.
This makes they good for supplying power to LED, rather than reading the sensors.
If the OUTPUT pins are short-circuited and connected to the ground or 5V circuit, they will be destroyed and even be burnt out.
When pin Atmega is supplying power to the relay or motor, because of the shortage of the current, some external circuits are needed to supply power.