Auto-Off NeoPixel Articulated Reading Light

2,038

63

22

Posted

Introduction: Auto-Off NeoPixel Articulated Reading Light

My wife and I have had many reading lights over the years. We attach them to the headboard. We read. We fall asleep. And then sometime in the middle of the night, around 1am or 2am, we end up waking up to turn off the light. To me, the sleep disruption seemed unhealthy. In addition, it's very annoying being woken up by the other person's light and either having to reach over to turn it off or wake the other person up to tell them to turn it off. Lastly, we have kids who each have their own reading lights Sometime they turn them off before they fall asleep, but often not.

So this project is a prototype for a little smarter reading light.

UPDATE: 2016/10/10

The base has been increased to accommodate a 4x AAA battery holder. 3D models have been updated.

Step 1: Parts and Tools

Parts

Tools

The biggest tool that's needed is a 3D printer. I have an Ultimaker 2. Any quality 3D printer that can print at least 160mm tall projects will do. As for the rest of the tools:

  • Soldering iron (for the electronics)
  • Wire cutters (for the electronics)
  • Screwdrivers (for the armature)
  • Exacto knife (for 3d print cleanup)
  • Tweezers and needle nose pliers (for 3d print cleanup)
  • Picks and dental scrapers (for 3d print cleanup)
  • Dremel (for 3d print cleanup)

Step 2: 3D Print the Parts

This will take the most time, approximately 5 days of on and off after work and through the night printing. It'll take longer if the printer has glitches, like my Ultimaker 2 does. Also, if it doesn't print true, be prepared to a lot of post print cleanup. All of the detailed slicing information applies only to the slicer that I used, which is Cura. Lastly, make sure that there is enough filament in the desired color.

Print the following:

  • base
  • base lid
  • top clamp
  • light housing
  • nut
  • arms; how many of what type is a matter of personal preference
  • connectors; a pair for every articulation point
  • knob

The Screw Clamp

A bit about the screw clamp. I was trying to find numerous ways to clip or clamp the reading light onto my headboard rail. With what I had around, it was a bit difficult to find a clip that I could use that look pretty nice. Chip bag clips aren't really strong enough. Binder clips and hardware clamps don't really look good. Without a way to make a strong clip spring, it's hard to make a clip. So I resorted to a screw clamp.

Nearly all screw clamps use metal either for the bolt or for the nut or both. The few that used plastic and was 3D printed were mostly small. I needed something that could take some bit of force. Searching around I found How to build internal and external metric ISO threads in 123d design v2.0 by drive3D. Following his instructions, which after doing it once I found it very simple, and referring to Maryland Metrics Thread Data Charts, Metric Thread Course Pitch for thread dimensions, which specifies unique dimensions for both the bolt and the nut, I was able to create a M36 nut and bolt. I was very pleasantly surprised to find that my test print worked perfectly first time. It's not going to hold up a building, but it will keep the reading light onto a table top or headboard rail.

Base

This is the most complex piece in the group. Make sure that it prints true, that any kind of brim or raft option is used, and that whatever stick technology works for the printer is being used. With all of the experiments and failures, it took me 1 solid week to get something working

Print time: ~15 hours

  • Fast print
  • Enable retraction: disabled
  • Fill Density %: 75
  • Print Speed mm/s: 30
  • Support type: touching buildplate
  • Platform adhesion type: Raft
    • Extra margin: 15mm
    • First Layer Airgap: 0.1

Reading Light - Bottom Base (increased size) by gary fong on Sketchfab

Base Lid

The lid that attaches to the bottom of the base so that the electronics don't fall out :)

Print time: ~1 hour

  • Fast print
  • Enable retraction: disabled
  • Fill Density %: 20
  • Print Speed mm/s: 50
  • Support type: none
  • Platform adhesion: none

Reading Light - Base housing lid by gary fong on Sketchfab

Print time: ~4 hours

  • Fast print
  • Enable retraction: disabled
  • Fill Density %: 75
  • Print Speed mm/s: 30
  • Support type: none
  • Platform adhesion: none

Reading Light - Nut by gary fong on Sketchfab

Top Clamp

This along with the bottom housing is what keeps the light onto a table or headboard rail.

Print time: ~2 hours

  • Fast print
  • Enable retraction: disabled
  • Fill Density %: 20
  • Print Speed mm/s: 50
  • Support Type: none
  • Platform Adhesion: none

Reading Light - Top Clamp by gary fong on Sketchfab

Light Housing

Print time: ~2 hours

  • Fast print
  • Enable retraction: disabled
  • Fill Density %: 20
  • Print Speed mm/s: 50
  • Support Type: Touching buildplate
  • Platform Adhesion: Brim

Reading Light - Light Housing by gary fong on Sketchfab

Arms

There are 3 arm lengths. Each is a third size bigger than it's smaller version. I thought I would need all three but instead I only used 1 medium and 3 smalls.

Print time for small: ~1 hour

Print time for medium: ~1.75 hours

Print time for large: ~2.5 hours

  • Fast print
  • Enable Retraction: disabled
  • Fill Density %: 50
  • Print Speed mm/s: 50
  • Suport Type: Touching buildplate
  • Platform Adhesion: Brim

Reading Light - Small Arm by gary fong on Sketchfab

Reading Light - Medium Arm by gary fong on Sketchfab

Reading Light - Large Arm by gary fong on Sketchfab

Arm Connector

A pair of these need to be printed for every articulation point in the armature. Cura has the ability to print multiple copies one at a time. I was able to fit up to 10 on the plate.

  • Fast print
  • Enable Retraction: disabled
  • Fill Density %: 50
  • Print Speed mm/s: 50
  • Support Type: none
  • Platform Adhesion: none

Print time: ~13 minutes

Reading Light - Armature Connector by gary fong on Sketchfab

Knob

Control knob

Print time: ~30 minutes

  • Fast print
  • Enable Retraction: disabled
  • Fill Density %: 50
  • Print Speed mm/s: 50
  • Support Type: none
  • Platform Adhesion: none

Post Print Cleanup

Most of the work will be removing any support material, removing strings, smoothing off dots, glue or any residue from the sticky plate technology, etc. Make sure the balls are as round as they can be. Also make sure that the lid fits into the base housing bottom. The rotary encoder has a D-shaft. Make sure that it fits into the knob. Lastly, there are a total of 9 screw holes: 4 in the base, 4 in the lid, and 1 in the knob. Make sure that they still exist. Use a tiny drill bit or something to drill out the hole if it got covered or filled in.

Step 3: Electronics

Surprisingly, the electronics part of this project is pretty simple especially when using an Arduino Nano. I tried using a Trinket but because of the number of pins I needed, I had to use the ones that aren't really supposed to be used which caused all kinds of problems. Luckily the reading light base can hold an Arduino Nano very easily.

Rotary Encoder

This encoder with the switch acts like a button dial on a modern car stereo. It continuously rotates left or right and can be pressed down to act as a momentary button switch. The encoder library from PJRC works perfectly with the encoder feature. And Bounce2 library is perfect for the switch.

Passive IR Sensor

This is a basic PIR sensor. It has a single data line signals high or low indicating if some motion was detected or not. There are two pots to control the sensitivity and the duration of the high signal. No special library was used to understand PIR signals. I wrote one, though, to just encapsulate the sleep logic as detected by the sensor.

NeoPixel Ring

The NeoPixel ring is a ring of addressable NeoPixels which are basically RGB LEDs. The ring should be a true ring that works with the Adafruit NeoPixel library. I introduced a modified version of the NeoPatterns library to provide the mood lighting.

The Code

The code can be found in my github repository.

Step 4: Assembly

This assembly is somewhat temporary. The primary reason is that the programming is still in flux. Not until the reading lamp in actual use will I know if anything needs to be tweaked or not.

Test The Electronics

First things first. Wire up the electronics and run the Arduino code to make sure everything works. Don't continue until this step works.

Light Housing

  • Cut 4 lengths of wire long enough to reach from the light housing down the arms to the base housing plus a bit more. They'll be used for positive, negative, PIR data and NeoPixel data.
  • Cut 2 more small lengths of wire, about 4", one black, one red
  • Solder the red to VCC on the NeoPixel ring
  • Solder the black to the ground on the NeoPixel ring
  • Solder the yellow to the Data In on the NeoPixel ring
  • Solder the green to the Data Out on the PIR sensor
  • Put a non-conductive barrier, such as tape, between the solder points of the capacitors on the PIR and the NeoPixel ring. The NeoPixel ring exposes some some copper and the solder of the PIR could make contact.
  • Hot glue the PIR sensor onto the back of the NeoPixel ring in the center of the ring
  • Solder the small red wire from VCC on the NeoPixel to the PIR VCC
  • Solder the small black wire from ground on the NeoPixel to the PIR ground
  • Feed the wires through the light housing
  • Hot glue the NeoPixel ring into the light housing

Armature

  • Feed the wires through each of the arms. Make sure the arms are in the preferred order. Near the top I have 3 small arms and at the bottom 1 medium arm.
  • For each of the connectors apply heat shrink tubing over each concave joint. Shrink it. The tubing will provide friction between the ball and the connector.
  • Attach two connects between each joint joined with a screw, a washer on both ends, and a butterfly nut. Do not over tighten.
  • Before connecting the next link, exaggerate the bend in the prior links. This will provide slack for when it's needed.

Base Housing

  • Place the top clamp over the base housing
  • Use a bit of beeswax (or paraffin) on the threads of the nut and the base housing
  • Place the nut on the base housing atop the clamp
  • Feed the wires through the base housing
  • Attach the final connectors between the base housing and the armature

Electronics

  • Connect the Arduino Nano to the breadboard
  • Strip and tin the wires
  • Attach the wires to the breadboard based on the fritzing diagram in the previous section
  • Cut 3 small lengths of wire, black, green, and yellow
  • Solder the black onto the ground of the encoder
  • Solder the green onto channel A of the encoder
  • Solder the yellow onto channel B of the encoder
  • Attach the encoder's wire to the breadboard based on the fritzing diagram in the previous section
  • Cut 2 small lengths of wire, white
  • Solder the white wires to the switch leads on the encoder
  • Attach the switch's wire to the breadboard based on the fritzing diagram in the previous section
  • Attach the 10K Ohm resistor on the button signal and the ground
  • Cut 3 small lengths of wire, 2 red and 1 black
  • Attach a red wire to the SPST toggle switch lead
  • Attach the other red wire to the battery pack
  • Attach the black wire to the battery pack
  • Attach the red wire that goes to the SPST to VIN on the Arduino Nano
  • Attach the black wire from the battery pack to ground on the Arduino Nano

Rubber Pad

To help keep the light from spinning when it is attach to something round, like the metal round stock of a headboard, attach two pieces of rubber to the faces of the top and bottom clamps. I used scraps from an old bicycle tube that I keep around for just this purpose. The tube has power residue to keep the tube from sticking together. Wash it off. Then cut and glue the pieces onto the clamp faces.

Step 5: Auto-Off Algorithm

One of the goals of creating the reading light was to have it turn off when it detects that I have fallen asleep. The current algorithm uses motion detection and frequency.

The way it works is as follows:

  • An awake movement is any motion that lasts longer than 5 seconds
  • The light records movements for a 5 minute period
  • If after 5 minutes there were less than 15 movements, the person is considered asleep
  • The light is then turned off

Right now it's crude. This is one of the reasons why the Arduino Nano still sits in a breadboard. That give me the ability to pull it out, change the algorithm, put it back in, and then give it another try.

4 People Made This Project!

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge
user

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

Tips

Questions

14 Comments

if i conect it like the fritzing and the ROTARY`s both grounds the COMMON and the other black wire on the 2pin side.

ITS NOT WORKING

when i replace the black wire (NOT THE COMMON) to D4, it startsup in the serial and you can then see what i already posed here the movemends and rotary changes.

BUT STIL NO LIGHT.

so i hope you now have enought info to help me out good this time

WannaDuino!!!

And as extra voltage info! ( it must be the CODE )

The ring gets from the arduino nano on the+- inputs of the ring 4.40Volts.

What's yours? i think its just to low but. and of corse, there are different rotary modes so the voltage wil climb up and down by some colors.

but 4.4V is on LIGHTS MOOD FAST. but wil be good to know what this weird flaw is.

i just can't get it loose.

i also tried other rings and ws2812B bars and so. al NOT working.

so either its a wrong pin

or your own code is different,( i think that last one)

there must be another pin input that is not in this code you provide.

and also not seen in the fritzing.

its so simple there are 3 attachments

1 ring +- and the pin out.

2 PIR sensor +- and the pin out

3 the ROTARY A to pin(2 ) B to pin (8 ) C (Common) to pin ( GROUND)

and the other 2 PINS ( ) ( ) ?? not explained in the code. yeah 1 pin is also GROUND. as you did in the FRITZING.

so stil 1 pin not in the CODE so i think that that is it.

But i am just a beginner and dont no nothing about coding and commands.

WannaDuino!!!

look is differend then the fritzing

pins.png

Yes the PIR i know its pin9

What i think about the 10K resistor is that you have it already in your build, and probably also on the good pin also. funny isn't it.

But as you see, mine is stil not wworking, can you make some pictures plaese so i can re check everything for me and you,

than this IBLE is BOMBPROOF.

i also bin looking for a 3D printer now. I like those things so mutch, i am thoinking of the PRUSA3 MK2. not the original but a cloon from banggood or here from the Netherlands. banggood cost around the 450 euro 500USD almost

is a good bargin but as you also know, its the firts 3D printer for me so i am PRO-CONNING a lot.hahaha.

yes i know ( BUY IT!! ) bút its holding me back a bit.

but what i seen what builds people can do with a printer, like your amazing light, i whas stunned.

please HELP

You are right. I put up a new image.

Pin 6 was and still is correct.

Pin 3 was and still is correct.

Pin 2 wasn't specified. Now it is correct.

Pin 8 wasn't specified. Now it is correct.

Pin 9 was and still is correct.

That`s awesome, new friend.

i was getting NUTS, i was really thinking that i did wrong. But i could not let it go, so i bin de-coding al your input.

A finally i seen the mistakes. (WannaDuino ) a beginner.

I am glad i was right, and that we together can correct it.

Because this is a AWESOME IBLE.

I wil reconnect al the parts, and hopefully it will finally SHINE!!!!!!

But if possible, please respond direct, oke?

From Holland, WannaDuino!!!

need help, the code is not working with my setup,

i think also that your code has other pinouts? and your frtsing is wrong, what the rotary encoder conserns, look at the datasheet. A and B are in your drawing 5V and GRND. or the datasheet is wrong but i can not get it to work. and can you give me also the pin nr`s of al the items? becous its not clear for me in the code , what what is., i got EXACT the same setup.

so pleace help friend oke?

WannaDuino!!!

pins.pngrotary.pngrotaryy.png

I've been thinking about ways to build the lamp without a 3D printer, but I have not started. However, it'll probably involve welding since I'm taking a welding class. But I think I may find a way to use brazing instead, which just uses a torch. I just need to find the time.

today i am beginning with this project to,

but i have no 3D printer but that wil come later.

hope i get some help if needed.

WannaDuino!!!

Sorry. Been busy. Extension sounds like a cool idea. Ultimately, though, I personally didn't want anything hanging out the back once the algorithm has been established.