In the picture below, the LED is connected to the 5V and to the digital pin 2. My question is, shouldn't it be to connected to a GND pin instead of the pin 2 ? Since when pin 2 is configured as output, isn't the current going from pin 2, to the LED, to the 5V? And at the same time from 5V, to the LED, to pin 2 ? I might have a wrong understanding of how digital pins work, so any help is appreciated. Thanks in advance.
Hi and welcome.
Your digital pin can be either HIGH or LOW.
When it is HIGH it will source 5 volts from the pin, which most people new to all this will see as switching a device on.
When it is LOW it will sink towards GND (0 volts), and for technical reasons it will be better able to do that than sourcing.
The LED doesn't mind how you power it, it will be happy when there is a difference between Anode and Cathode of Vforward.
When the pin is HIGH, there will not be enough voltage.
When it is LOW there will be enough.
So from now on, get used to switching devices on by putting a pin LOW.
It doesn't matter for the device as long as you do that to the right pin of that device, and there's no consequences to the software than using the right term (LOW) to switch on.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.