Showing posts with label dimming. Show all posts
Showing posts with label dimming. Show all posts

Wednesday, April 16, 2014

LED dimmer part 2: motion activated

My PIR motion sensors finally arrived today. I added one to the LED dimmer from the previous post. The motion sensor acts like an on/off switch that you can override using the touch sensor.

The motion sensor detects movement using infrared and it outputs a high signal when it does. This triggers the dimmer into its on state. A couple of seconds after the signal goes low (no motion) the dimmer goes into off state.


While the dimmer is on (caused by the motion sensor), you can force it off using the touch sensor. There are two potentiometers on the sensor; one for sensitivity (I left it at center position) and one for time. The time pot controls for how long the sensor will output a high signal after detecting motion. I use the lowest setting and handle the rest of the timing in the micro controller since tuning the pot is really inaccurate and annoying. There appears to be a forced 4 second delay between two high signals. No idea if that can be trimmed or not.
There's also some space allocated on both sides of the sensor board for a light sensor, so it will only detect motion when it's dark.

The Arduino program can control up to 6 output channels (could be more, but it doesn't look like I need more) and has 8 inputs, any of which can be motion or touch sensors. There are 256 levels of brightness, but the distribution of actual brightness does not seem to be very linear, it looks more logarithmic to me; it ramps up to full brightness really fast and doesn't do much after that. I'd like to have better control in the low brightness region...

Sunday, April 13, 2014

Adjustable single button LED dimmer

I'm planning on adding some LED strips to my bed. I currently have one small light next to it, and it's always annoying to find the switch, it often ends up with the light on the ground. And when it's on, it's usually too bright. So I thought, what if I add a LED strip to the back of my bed? And what if I could switch it on and off by just touching some part of the frame?

I have one of these IKEA bedframes. Putting a LED strip on the back of the headboard should provide a decent amount of light. Adding a capacitive touch sensor at a sensible, easy to reach part of the frame would make a nice on/off switch, possibly concealed by a piece of matching veneer for good looks.

But what about the brightness? I'd like to be able to control the brightness without having to deal with potentiometers or reprogramming. Well, my sister in law has one of those IKEA lamps that you can turn on and off by just touching it. What's even cooler is that you can adjust its brightness by just holding it.

The logic behind it is pretty simple. Touch (a button) shortly and it will switch the light on/off. Hold it longer and the brightness increases until it reaches full brightness, after that it will decrease. If you let go and hold it again the direction of brightness change also changes. Like this:


I'm using a touch resistor here since my capacitive touch sensors haven't arrived yet, but the effect is almost the same. Touching that strip at a given place will make it have a resistance between 0 and 10KOhm. It's like a potentiometer and the strip is the wiper.

I'm using a small BC337 transistor here to drive the LED, but I can use it for LED strips as well (up to about 1.5 meter) which will be perfect.

There's also a bit of fading code in there to smoothly turn the light on and off. The PWM signal is generated in software using a timer. The code is not really worth sharing at the moment and shouldn't be hard to figure out.