Random Arduino LED Fader.

by blinkyblinky in Circuits > Arduino

28103 Views, 30 Favorites, 0 Comments

Random Arduino LED Fader.

PC121965.JPG
PC121962.JPG
Randomness. It is so easy in the real world. In the electronics world, well...it is really hard. Sure it is possible to create "pseudo-random" effects but not truly random. The only way to actually create randomness is to use programming. Even then, randomness will eventually repeat itself.

Fading. It is also hard.Without programming, it is possible but it is not efficient. The circuits aren't small. In fact, most fading circuits use large capacitors that take up space. Not pleasing.

Put these two together and it is extremely tough to make.

In the end, I must subject to programming.

To be specific in this case,

Arduino programming. 

This project involves Pulse Width Modulation and is achieved through the use of an Arduino, a computer and a breadboard with LEDs. Inverting a signal will be achieved through the use of sinking and sourcing.


Update: I changed the code a bit. It now fades a bit faster and a bit better and smoother to view. If you downloaded the code look again at the code.

What You Need.

You will need:
An Arduino
6 LEDs (possibly more.)
Jumper Wires
Breadboard and/or protoboard
 

Programming.

PC111948.JPG
PC111947.JPG
Program the Arduino with the code below. It will give you a slow fade from each LED.

Circuitry.

PC111945.JPG
Take the ground of each LED and connect it to the ground rail of the breadboard. Connect the positive leads to pin 3, 5, 6, 9, 10, 11 on the Arduino. 

Fading Away!

PC111944.JPG
Now, the LEDs should fade in a pseudo-random way. You are done but, for less impressed people, click "Next Step."

Sinking and Sourcing.

PC121954.JPG
Here's how I teach sinking and sourcing.

By sinking, I mean from output pin to ground. By sourcing, I mean from positive to output pin. 

Think of it this way. Power can flow from the LED to the pin in sourcing. In sinking, power comes from the pin. Power is always coming into the pin so, when the pin goes high, the current "passes" through the LED to the pin thus, turning it off.

To most people, they should say, "What difference does it make?"

To moi, a random person, it means, "I can invert signals thus create more randomness!"

Remember, to avoid using a resistor (living dangerously) power it from 3.3 volts.


Doing So...

PC121954.JPG
Now take pin 3 and source it.

Take pin 6 and source it.

Take pin 9 and source it.

Then, take pin 11 and source it.

Leave the rest where they are.

Really Done.

PC121950.JPG
PC121951.JPG
PC121952.JPG
PC121953.JPG
PC121955.JPG
PC121956.JPG
PC121957.JPG
PC121958.JPG
PC121959.JPG
PC121960.JPG
PC121961.JPG
PC121962.JPG
Now, a random effect can be achieved (time for me to evily cackle) (excusez-moi...BWA-HA-HAHA-HA!)

Done.