Skip to main content
Added details
Source Link
G-aura-V
  • 1.1k
  • 1
  • 8
  • 25

The key you are missing in the understanding is the fact that the pins have three states. The states are high state, low state and HIGH IMPEDANCE state. When you have the pins configured as digitalWrite(), the pins can be set to either high or low state with digitalWrite(pin,HIGH) and digitalWrite(pin, LOW) respectively. When the pin is set to HIGH mode, the digital pin acts like conncection to Vcc. When the pin is set to LOW mode, the digital pin acts like conncection to ground and this is what you are talking about.

But when you set the pin to read with digitalRead() function, you set the pin in high impedance mode.

schematicschematic

simulate this circuitsimulate this circuit – Schematic created using CircuitLab

The above schematic is the illustration of how the Arduino is actually configured. Here, when the input is configured to INPUT state, the 1 GOhm impedance comes into action. Thus there is no path to ground through the digital pin.

How the circuit works then?

Well, this is pretty simple to understand with the concept of HIGH IMPEDANCE state of input pin. When the dip switch is off, there is no current flowing through the 220Ohm resistor. Thus there is no voltage drop across it meaning the node you are checking at has the same potential as the ground.

When the dip switch is on, there is path for the current to flow throught the resistor. Since the input impedance is very high, the current takes the path of 220 Ohm resistor. Now, the node you are checking is at +5V. (I am assuming your red wire is supplying +5V.)

The key you are missing in the understanding is the fact that the pins have three states. The states are high state, low state and HIGH IMPEDANCE state. When you have the pins configured as digitalWrite(), the pins can be set to either high or low state with digitalWrite(pin,HIGH) and digitalWrite(pin, LOW) respectively. When the pin is set to HIGH mode, the digital pin acts like conncection to Vcc. When the pin is set to LOW mode, the digital pin acts like conncection to ground and this is what you are talking about.

But when you set the pin to read with digitalRead() function, you set the pin in high impedance mode.

schematic

simulate this circuit – Schematic created using CircuitLab

The above schematic is the illustration of how the Arduino is actually configured. Here, when the input is configured to INPUT state, the 1 GOhm impedance comes into action. Thus there is no path to ground through the digital pin.

The key you are missing in the understanding is the fact that the pins have three states. The states are high state, low state and HIGH IMPEDANCE state. When you have the pins configured as digitalWrite(), the pins can be set to either high or low state with digitalWrite(pin,HIGH) and digitalWrite(pin, LOW) respectively. When the pin is set to HIGH mode, the digital pin acts like conncection to Vcc. When the pin is set to LOW mode, the digital pin acts like conncection to ground and this is what you are talking about.

But when you set the pin to read with digitalRead() function, you set the pin in high impedance mode.

schematic

simulate this circuit – Schematic created using CircuitLab

The above schematic is the illustration of how the Arduino is actually configured. Here, when the input is configured to INPUT state, the 1 GOhm impedance comes into action. Thus there is no path to ground through the digital pin.

How the circuit works then?

Well, this is pretty simple to understand with the concept of HIGH IMPEDANCE state of input pin. When the dip switch is off, there is no current flowing through the 220Ohm resistor. Thus there is no voltage drop across it meaning the node you are checking at has the same potential as the ground.

When the dip switch is on, there is path for the current to flow throught the resistor. Since the input impedance is very high, the current takes the path of 220 Ohm resistor. Now, the node you are checking is at +5V. (I am assuming your red wire is supplying +5V.)

Source Link
G-aura-V
  • 1.1k
  • 1
  • 8
  • 25

The key you are missing in the understanding is the fact that the pins have three states. The states are high state, low state and HIGH IMPEDANCE state. When you have the pins configured as digitalWrite(), the pins can be set to either high or low state with digitalWrite(pin,HIGH) and digitalWrite(pin, LOW) respectively. When the pin is set to HIGH mode, the digital pin acts like conncection to Vcc. When the pin is set to LOW mode, the digital pin acts like conncection to ground and this is what you are talking about.

But when you set the pin to read with digitalRead() function, you set the pin in high impedance mode.

schematic

simulate this circuit – Schematic created using CircuitLab

The above schematic is the illustration of how the Arduino is actually configured. Here, when the input is configured to INPUT state, the 1 GOhm impedance comes into action. Thus there is no path to ground through the digital pin.