Random Arduino LED Fader.
by blinkyblinky in Circuits > Arduino
28103 Views, 30 Favorites, 0 Comments
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.
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
6 LEDs (possibly more.)
Jumper Wires
Breadboard and/or protoboard
Programming.
Program the Arduino with the code below. It will give you a slow fade from each LED.
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.
Fading Away!
Now, the LEDs should fade in a pseudo-random way. You are done but, for less impressed people, click "Next Step."
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.
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...
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.
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.
Now, a random effect can be achieved (time for me to evily cackle) (excusez-moi...BWA-HA-HAHA-HA!)
Done.
Done.