Here are the components that you will need.
- 1 x Arduino UNO
- 1 x Breadboard
- 1 x P2N2222AG transistor
- 3 x LEDs (1 x Red LED, 2 x Yellow LEDs)
- 3 x 330 ohm Resistors
- Wires to connect it all together.
We will use Pulse width modulation (PWM) to fade the LEDs in and out.
Load the "Fading" example into the Arduino. (File>Examples>Analog>Fading)
I used this sketch to help me understand how electricity flowed through the transistor by disconnecting a wire here and there. I am not sure if this is advisable, so do this at your own risk. If you are an electrical engineer, feel free to comment. Please let me know if this is "risky" business.
I have had no formal training in electronics, so don't blame me if your arduino, or transistor blows up !
But from what I understand, I cannot see any harm in disconnecting wires with this particular circuit.
Please note, that I would disconnect the power to the arduino before modifying the wires.