Sunday, September 18, 2011

Fade in, Fade out

Example 4 showed us how to fade an LED in and out (like a Macbook while it's sleeping, I hesitate to exemplify). This is essentially simple. The Arduino's analog outputs allow you to send an integer between 0 and 255 which corresponds to pulse-width modulation, which in turn corresponds to the brightness of the LED. So looping an integer variable from 0 to 255 and back with a 10ms delay allows the LED to fade in and out every half second or so. I have no pictures because I got ahead of myself and started building the next circuit, but luckily the circuit necessary for Example 5 happens to combine the circuits from Examples 4 and 3. Let's take a look:

Rather a quintopus of a circuit
Though it's hard to distinguish given the quality of my cell phone's camera (Dirty South), the button circuit from the last example has basically been pushed to the right and connected to an LED circuit. This is an example of how basic elements can be joined together to make a more complex whole.

So now, when you press the button, it turns on or off. When you hold the button while turning it on, the brightness changes. This is done by checking to see whether the button has been held for longer than 500ms and whether the light is currently on.

Next time, we control the LED based on some more continuous analog input: a light-dependent resistor.

And after that, we connect a few LEDs to the internet and alter them based on RSS info... and then on to the meat -- the Vitamaster itself.

2 comments:

  1. Isn't it PWM on a digital pin that is making the LED glow a specific intensity? I like the blog. It's good to see you are working towards your goal.

    ReplyDelete
  2. Whoops, you're right. I'll have to fix that.

    ReplyDelete