Close
0%
0%

Motion Controlled Cabinet Light

An LED strip of white LEDs that can be turned on, dimmed, and turned off with a wave of your hand

Similar projects worth following
In our kitchen, the light that falls on the counter is blocked by the kitchen cabinets. It would be nice to have some light when preparing food, but often when you need light, your hands are dirty. I came up with the idea of running a strip of LEDs under the cabinets and being able to control them by waving your hand under the cabinet to turn them on. You can adjust the brightness by moving your hand down from just under the cabinet to counter level to control brightness based on the distance from the cabinet.

I am using an ultrasonic range sensor to determine the hand distance between the cabinet and the counter. I don't want to run the sensor all the time because, even though we can't hear the 40kHz chirp, I imagine the dogs and bird (our pets) can hear it. Additionally, I imagine there is a limited lifetime on the sensor. So I added a pyroelectric infrared (PIR) sensor that will only activate the ranging when it senses movement around the counter.

I wrote some software for the ATTiny85 to manage all this. That will be forthcoming soon.

Since I am using an ATTiny85, I couldn't use the Arduino environment to program it, readily. I think there are some ways to configure the environment to do it, but in the end, it was just easier to set up an Eclipse environment with the AVR GCC compiler and program my own PWM (for dimming LEDs) and millisecond counter (i.e. the "delay" function).

Here's the flowchart for the processor:

When no hand is present, the range is the distance between the sensor underneath the cabinet and the top of the counter. This is the "Max" distance

The "Min" distance is some range above '0' (because the sensor can only resolve distances above around 1 cm).

A Hand is "near the cabinet" when the measured range is in the lower 10% of the range between Min and Max.

A Hand is "Removed" when the range is in the top 10% of the range between Min and Max.

When a distance is measured, the Min and Max values are saved to create a range between the bottom of the cabinet to the top of the counter.

I found that due to humidity and temperature changes, the Max range can 'drift' over time. To compensate for this, whenever the State is "Off" and the Ultrasonic sensor is pinging for the presence of a Hand, the Max is decremented so that the Max range can be refreshed. Otherwise, the 10% max range I use to determine the removal of the hand would "disappear below the counter" over time and the user would never be able to escape the Ranging State.

  • 1 × ATTiny85 MCU Running on the internal 8 mHz clock
  • 1 × MOSFET Driver for the string of LEDs
  • 1 × Strip of LEDs, 30 pixels/meter, bright white
  • 1 × 4.7 uF Capacitor For power supply stability
  • 1 × 10K Resistor Pullup for the reset line

View all 11 components

  • I Got Skulled!

    Thomas Snow03/19/2015 at 10:48 0 comments

    I would like to thank the Academy...

    Seriously, the ability to share ideas and be inspired by others' creations is why I am on this site. I suspect that the mention I got on the Hackaday Blog is the reason for the attention my project has gotten, lately, but it's nice to know people are interested in something that I've done.

    Keep Hacking, everyone!

  • LED Installed and Working, But...

    Thomas Snow03/15/2015 at 12:06 0 comments

    I had to leave out the PIR sensor for now. I had designed the board to use the 3x2x1 plastic enclosure that you can find in any Radio Shack. I checked that I could fit the PIR and Sonar sensors into the lid (after drilling holes), but what I didn't count on was the room that the wires and pins would take up. I couldn't fit everything in, so I need to find another project box that is relatively flat (the 1" depth exposes the box underneath the cabinet) and can accommodate everything. Ideally, I want a box that is 4.5x2.5x0.75.

    So I took out the PIR and have the sonar sensor pinging continuously. It works well, but I think I'm going to do some sort of averaging algorithm on the readings. The lowering of the intensity by lowering your hand from just under the sensor (activation) is jumpy and 'locks' too quickly (when it gets an erroneous reading, thinking the hand was removed).

    Below is a demonstration. What is interesting is the tapping you hear is the sonar sensor, but you can't hear it normally. I guess my phone picks it up just like video cameras pick up IR light.

  • First Build

    Thomas Snow03/14/2015 at 12:05 0 comments

    I built up the first board and did some tests. All seems to be as planned. I now need to drill out the holes in the project box and enclose everything. I have the LED Track cut and drilled, ready to install. The LED strips have been cut and joined (they are going to be installed in a corner cabinet area).


  • The Boards Are In!

    Thomas Snow03/13/2015 at 13:53 0 comments

    Looks like my weekend is sorted!


  • PIR and Sonar Sensors are in

    Thomas Snow03/12/2015 at 14:47 0 comments

    I received the PIR and HC-SR04 sensors from China. The PIR sensors are working fine. The HC-SR04 sensors have a problem though. These are the 4 pin models (VCC, GND, Trigger, and Echo) which is different than the Radio Shack model I have been using, which is 3 pin. The 3 pin version multiplexes the trigger and echo. This isn't the problem because I planned for the 4 pin model. While these 4 pin Chinese models seem to provide a more stable reading (the 3 pin version seems to jitter a lot), if there is no return echo (i.e. you ping across a large space), they lock up. The 3 pin RS model will time out after about 40 ms. I read somewhere that this is because there is a faulty bit of code in these cheap Chinese versions. I don't know if they can be reprogrammed.

    The only way to reset them is to power them down and back up again. I have the Reset pin of the ATTiny85 on the connector for the sensors (in the event I wanted to repurpose the boards) and I could program the chip to use it as an I/O line to bounce the sonar when it gets in this state, but once you program the chip to not use the reset pin, you can't easily reprogram it. There is some information that says you can use 12V on the reset pin to override this, but I will have to wait until I put together a programmer for it. So for now, I will be using the 3 pin model.

  • PCBs Have Shipped

    Thomas Snow03/07/2015 at 13:24 0 comments

    I've just received notice that my PCBs have been shipped. I hope to get them by next weekend and if I do, I will be installing the lights under the cabinets. I am getting them from Dirt Cheap Dirty Boards.

  • Tracks Are In

    Thomas Snow03/06/2015 at 21:08 0 comments

    I just had the tracks for the LEDs delivered. These will be mounted under the cabinets over the counter. I got them from here.

  • LED Strip

    Thomas Snow03/01/2015 at 13:15 0 comments

    I am using an LED strip of bright white LEDs that have a density of 60 LEDs per meter. I got 10 meters of the stuff. The company was selling them in two 5 meter rolls. I got them here.

  • Ordered Some More Parts

    Thomas Snow02/27/2015 at 13:49 0 comments

    I decided that once I get this project working well, that I might make several for family and friends that might need something like this. To that end I placed an order for some HC-SR04 (Ultrasonic Ranging Module) and the HC-SR501 (PIR Sensor) modules from a company in China. They're dirt cheap compared to what you can get them for in the US. Adafruit is selling the PIR sensor for $9.95 vs. the 87 cents I paid in China (and you know they are getting them from the same place!). Radio Shack sells the Ultrasonic sensor for $29.95 vs. the 89 cents I paid in China. I bought 20 units a piece (which gave me a price break from 92 and 90 cents, respectively - and free shipping!). I've bought quite a bit of stuff from China through a web site called AliExpress, which looks like an online mall for the Far East, and have had no problems with any of the vendors. Granted, depending on the shipping method, delivery may take a while. I also got the LED strips and LED strip mounting rails from this site. Other stuff I got in the past were Arduino Mega 2560 for around $15 a pop and various forms of NeoPixels (strips of various densities and individual ones mounted on heat sinks - plan to use those for wearables or crafts), so I've had some successful dealing there.

    Both sensors are from the same vendor.

  • Prototyped

    Thomas Snow02/26/2015 at 20:38 0 comments

    I bread-boarded the prototype and I seem to have everything working. I used an Arduino Mega 2560 programmed as an ISP Programmer to program the ATTiny85.

    The PWM can control the brightness of the LEDs the way I want. The timer seems to be delivering the interrupts properly so that delay is as accurate as the internal 8 MHz clock will allow. I've gotten the range sensor to work correctly (tip: put some delay between samples, I suspect the delay should be long enough so all the pulses stop bouncing around the room, triggering false echoes - the bigger the room, the longer the delay).

    My only problem is making a circuit board. I managed to get the circuit on a Radio Shack PCB blank and etched it ok, after much trial and error, I must say. The problem came when trying to drill the holes. I bought some drill bits from Adafruit, but they snapped easily while drilling. I don't know what I'm doing wrong there. In the end, I laid out the board in Eagle CAD and am waiting for Dirty PCBs to make and deliver them. The amount of money wasted on toner transfer paper, etchant, PCB blanks, and drill bits is a lot more than the cost they are doing it for me!

    I'm also waiting for the LED tracks for under the counter.

    Once those are sorted, I'll be installing the lights. When I get them up, I'll post a Youtube video showing them in action.

    It's a cute little project and I am enjoying it. I'm also scoring some points with the Honey!

View all 10 project logs

Enjoy this project?

Share

Discussions

b.james wrote 08/10/2017 at 19:48 point

So You promised to add the software soon. A few years on now and no software yet . Will you ever put it up?

  Are you sure? yes | no

Thomas Snow wrote 08/10/2017 at 20:24 point

I wish I had.  A while ago I had a hard disk crash that took it out.

  Are you sure? yes | no

erhome00 wrote 03/17/2015 at 09:38 point

Hey there, I like your project and the documentation. But I got a question: Did you really use a 5V white LED stripe? Sounds very exotic to me. But according to your schematic it seems like you did...

  Are you sure? yes | no

Thomas Snow wrote 03/17/2015 at 11:10 point

For a light source, LEDs are not so exotic anymore.  They have become mainstream since pricing is so low, now.  And they are being put to use in some pretty impressive ways, especially in commercial architecture.

I used the 5V versions because I didn't need a lot of light, just enough to break up the shadows under the counter.  At the end of the day, the forward voltage on each LED is around 3V and I wanted to use a cheap wall wart (the one I am using puts out 1.5 amps).  There are various implementations of these strips (5V, 12V, and even AC). 

These are the LEDs I purchased: 

http://www.aliexpress.com/item/2-rolls-lot-60led-m-5V-3528-LED-Strip-white-warm-white-cold-white-non-waterproof/1404356041.html

  Are you sure? yes | no

erhome00 wrote 03/17/2015 at 12:16 point

Hey there, thanks for your fast reply. LEDs as light source are indeed not exotic these days but the 5V LED strips are not really common. I was just wondering if you really used a 5V strip and since the one you ordered is really cheap, it seems legit to use them for your purpose. :)

I think I will use your project as bases for a similar one - maybe with 12V LEDs and with an additional taser triggered by motion to stop my cats from triggering the lights and walking along the workplate :-)

I do really like the combination of the PIR and ultrasonic sensor in your project...

  Are you sure? yes | no

Thomas Snow wrote 03/17/2015 at 12:38 point

The reason that the 12V (and 24V) versions are so common is because these LED strings are usually used in large architectural constructions where their length can extend over 100 feet.  The last LED in the string is probably seeing around 5V anyway, but as long as there's enough juice to forward bias the LED, it will light up.  The line losses for a 5V string couldn't extend that far without additional power repeaters.  But if you are doing a short run, less than 5 meters, the 5V versions are adequate.

Good luck zapping your cat!  LOL

Right now I had to leave the PIR sensor out until I get some better boxes to put the circuit it.  They are on order.  I think the thing I learned from this project is that before you design the board and components, find the right box first and design around it.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates