Hello, everyone! I am a C++ programmer who recently found his world into the arduino world. I have been reading what I can, as I had ZERO experience with electric projects. I have a basic understanding now that allows me to make some cool things, but sometimes I honestly can not figure out how something works wiring wise! This for example:
How does this even work without a ground connection? Is it something to do with analog output o.O? I was under the impression that the ground is what attracts the electrons, and thus creates the flow of electricity through the circuit?
I can't make sense out of the picture you posted, but it is certainly possible to have current flow from one output pin to another, as long as one is HIGH and the other LOW, or from Vcc to a pin that is LOW.
Basically I am lighting a rgb led. I have the black wire powering it (5volts), and the colored wires as analog out (giving it rgb values). So its going from the 5v power pin to the LED and into the output pins? Where does it go after that and how does it loop?
I = (Vcc - Vpin) / R
Let's consider Vcc = 5V and R = 5Kohm (don't know your value. The current flows from Vcc to Vpin in case 1 only.
Case1 Vpin = 0V , I= 5v / 5kohm => I = 1 mA
Case2 Vpin= 5V , I=0v / 5kohm => I = 0mA
When you send , for example analogWrite(100), you keep the Vpin in 5v for 100 steps and 0v for the next 155 steps. You cannot see the LED blinking because all the 255 steps happen in 2 ms ( 1 second / 500). That is why you see it at "half light". The human eye makes a logarithmic average.
You have to be careful what resistances you take. High values are safe, but as above seen, you limit your current and your LED might not be as bright. Low values are not safe (one pin, if I remember correctly, is limited to 10mA).
I also have very little understanding of electronics, so if I am wrong, I would like to be corrected.
The current will flow from the lower potential to the higher potential. Thus if the analog pin value is set to say 125 then it will have about +2.5V potential. The other side of the circuit is plugged into +5V socket. The current will flow from the analog side (+2.5V) through the LED and resistor to +5V. You are assuming that the ground means 0V at the pin. It can be so but it does not have to be the case. If you set the analog output pin to 0 instead of 125 the pin voltage will be set 0V. Note that in both cases (2.5V and 0V) the analog pins being set below 5V serve as ground.
x50505:
I also have very little understanding of electronics, so if I am wrong, I would like to be corrected.
The current will flow from the lower potential to the higher potential. Thus if the analog pin value is set to say 125 then it will have about +2.5V potential. The other side of the circuit is plugged into +5V socket. The current will flow from the analog side (+2.5V) through the LED and resistor to +5V. You are assuming that the ground means 0V at the pin. It can be so but it does not have to be the case. If you set the analog output pin to 0 instead of 125 the pin voltage will be set 0V. Note that in both cases (2.5V and 0V) the analog pins being set below 5V serve as ground.
You are confusing the electron charges with the potential. Without opening a physics debate, the current always flows from HIGH potential to LOW potential. If you want to know how/why you can search over the internet.
The current will flow between any 2 different potentials given the appropriate components are between. So having a resistor with 5.001 V on one side and 5.000 V on the other side will "cause" the current flow. There is a misunderstanding on how analogWrite() function works. If you set it to 125 it will not give you 2.5v on the pin. It will give you 0v for a very short period (1ms) and 5v for the same period (1ms). Therefore the current will flow for 50 % of the time. If you put a multimeter it will show you 2.5V; not because this is accurate, but because the multimeter cannot measure that fast and it makes an average.
An LED behaves just like a diode ( and thus the name, Light Emitting Diode). It allows current flow only in one side: from ANOD to CATOD. So if you have 1v to CATOD and 0V to ANOD it will not flow. If you want your LED to light, you need to provide a voltage on ANOD that is higher then on CATOD. How much higher ? Depends on the LED. Most of them have 0.6v threshold. So , for example, if you apply at least 1v to ANOD and 0.4v to CATOD it should work.
LED forward voltages are larger than that for those operating in visible light.
Silicon diodes have about 0.6V forward voltage, red LEDs about 1.6V, blue about
3.3V. All diodes emit light when forward biased, its just that some are optimized
for it. Silicon diodes emit infra-red and are also sensitive to light, which is why
they are packaged in black epoxy normally.
Conventional current is a notional flow of positive charge around a circuit - the
fact that in metals the current is actually carried by negative electrons moving
the opposite direction can safety be ignored in nearly all circumstances as we
only care about the maths being right. In semiconductors and liquids charges
of either polarity may be involved in carrying current.