QuoteTo turn the LED red, pin1 is set HIGH and pin2 is set low, so the power goes one way. To turn it green, the polarity of the two pins is swapped, so the power goes the other way. Yellow is produced by rapidly switching between red and green, producing ACYou are not producing AC. AC is alternating current, where the voltage changes from positive to negative 50 or 60 times per second. All you are doing is switching which way the current, at +5V, is flowing.
To turn the LED red, pin1 is set HIGH and pin2 is set low, so the power goes one way. To turn it green, the polarity of the two pins is swapped, so the power goes the other way. Yellow is produced by rapidly switching between red and green, producing AC
an electric current that reverses its direction at regularly recurring intervals
Pulsating dc and ac are the same, a variable flow of electrons. The primary difference is the "Reference"... If "AC" is "Referenced" from the most negative level them you could say "It''s Just pulsating DC. Whether it is sinusoidal, square rectangular (duty cycle not 50%) triangular.Come to think about the definition a little and you will see that the prime requirement for AC... The one Difference that sets AC apart from noise is just Periodicity.It is the periodicity that sets it apart and allows it to do useful and predictable work is it's periodicity.Noise can be called AC... Pink noise (audio) and White noise (Full Spectrum) and random impulse noise are AC but because of the lack of predictability, little real work can be done with them.If you put in place a device that passes AC only, a capacitor or a transformer will pass your "DC" very well. it will also filter the signal due to its reactance or response to an "AC" signal... again the Periodicity.As to the library it does produce a signal that makes the LED light up Yellow... So the difference is?Just the point of reference... Put it in the right place and your "DC" signal becomes "AC".Place a diode in series and you remove 1/2 of the DC signal... Just as a diode would with AC... and you have DC again... pulsating but of one polarity... The signal cannot pull down when the input goes to it's lowest point because the diode will not conduct in the reverse direction.
#if defined(ARDUINO) && ARDUINO >= 100#include "Arduino.h"#else#include "WProgram.h"#endif