Random Arduino LED Fader.





Introduction: Random Arduino LED Fader.

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.

Step 1: What You Need.

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

Step 2: Programming.

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

Step 3: Circuitry.

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. 

Step 4: Fading Away!

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

Step 5: Sinking and Sourcing.

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.

Step 6: Doing So...

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.

Step 7: Really Done.

Now, a random effect can be achieved (time for me to evily cackle) (excusez-moi...BWA-HA-HAHA-HA!)




    • Epilog Challenge 9

      Epilog Challenge 9
    • Paper Contest 2018

      Paper Contest 2018
    • Pocket-Sized Contest

      Pocket-Sized Contest

    We have a be nice policy.
    Please be positive and constructive.




    how to make the fade faster


    You should use curent limiting resistors on your LEDs, baud rate didnt killed it!

    This works well, but the LEDs repeat a pattern.

    So, you're saying you made it?

    Also, did you sink and source?

    Yeah. I did sink and source, and I used your code. It starts out seeming random, but after a while a pattern emerges.

    Try rewiring the sink and source. Plus, don't stare at it too long otherwise the pattern will emerge.

    I will now rework the code.

    You've heard of the random function on the arduino right? have you tried using it in the code? I'm trying to use
    int x = random(1, 7)
    to get a random number, and list all of the combinations the lights could be, and use the number gotten from the result of the random function to randomly select one of the combinations (and yes I know that that would only be capable of choosing only 6 possible combination of something like 30 to 36.)

    I guess I'm more low-tech than I thought I was...


    I will try that.

    that's something I just learned today. I'm trying it now, so if I get it to work I'll post it here.