Why does this work?

Please explain why this works. It started as a slightly different project, which did not work, and, as I disassembled it, by chance I discovered a modified version of the first, which satisfies most of what I hoped to accomplish. I want to ask how to make the failed project work, but for now it would complicate my own understanding to refer to it.
The project uses the standard Arduino Example 03 Analog Fading sketch. The circuit in question involves two LEDs, instead of one, as specified in the Arduino example. The effect is that both LEDs fade in overlapping sequence. As the the first LED attains peak brightness, the second LED begins; when LED 2 reaches peak brightness, LED 1 goes dark, and so on.
The Example sketch includes a statement to increment brightness, but fades are separated by delay. My guess is there is a better way to write the sketch without blocking. That would be interesting to look at, but I am mystified why this works as is.
A Fritzing breadboard layout picture is attached. I am unsure how to correctly draw a schematic of the junction between the two LEDs, third resistor, and jumper wire to header pin 9.

Not everyone has your sketch.
Always show us your current compete sketch.
Use CTRL T to format the sketch.
Please use code tags. Use the </> icon in the posting menu.

[code] Paste sketch here. [/code]

In one case, the LED connected to +5v, has its current coming from 5v then going to GND through the O/P pin.
In the other case, the LED gets its current from the O/P then goes to the external GND.

Analog output makes the O/P pin go to 5v then to GND at a frequency ~400 hertz.
When at 5v it can supply current to a LED connected to GND, then when the pin is GND it can sink current from the LED connected the 5v.

.

Not sure why they have a 220 ohm resistor at pin 9.

When pin 9 is at GND the A current flows.
When pin 9 is at +5V the B current flows.

PWM signal at pin 9:

2017-07-14_21-56-40.jpg

.

just for my understanding. on a square wave 0vdc is GRD? or did I misunderstand that?

also could you post the code for this?

When the O/P pin is LOW/0VDC it is at GND potential.

.

Assume code is something like this.

for(byte x = 0; x <= 255; x++)
{
analogWrite(9, x);
delay(50);
}

.

Here is a fun one: if you put pin 9 in input mode, i.e. make it high impedance, both LEDs light up, as current flows through both LEDs and both wires, and not through R2.

As long as the forward LED voltage drops are less than 5 volts.

.

so GRD potential can be the "N" in a PNP?

"so GRD potential can be the "N" in a PNP?"

Well, if you are saying GND on the base of a PNP transistor will turn the transistor ON then yes it can.

However, not sure exactly what you are saying.

.

something like this

digitalWrite pin HIGH = PNP off

digitalWrite pin LOW = PNP on

In the attached drawing, Q2 (PNP) is controlled by pin D9 on the Arduino.

Doing a digitalWrite as you mention, will turn ‘OFF’ transistor Q2 with a HIGH and turn ‘ON’ Q2 with a LOW.

Outputs.jpg

.

ok thanks. that clears up the grd and 0vdc for me... I didn't realize you could use it for that.