Introduction: Auto-Off NeoPixel Articulated Reading Light

Picture of 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

Picture of Parts and 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

Picture of 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.


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


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


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

Picture of 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

Picture of 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


  • 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


  • 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.


WannaDuino made it! (author)2016-11-19

its working with the light

BUT, i changed the code.

i only changed pinout 6 to pin 7 and on that pinout it light up/

BUT only when the black ground pin is on D4.

and not as your fritzing connected to ground also on the ROTARY.

so thats stil a problem to be solved.

becous my rotary works half i think. i got some random color changing the rainbow, some fading but. problems with the switch part in on of and so.

and that has to do with the D4 pin part as i mentioned.

i begin to learn a lot in a short time using ARDUINO.

i like it!!!

so check it and read my other messages it wil help.

WannaDuino!!! is OUT.

gwfong made it! (author)WannaDuino2016-11-20

I attached blow up pictures of the nano board. I didn't use D7 or D4. Sounds like you did, though. I don't have any more unaccounted for.

As for the other 2 pins, they are the switch for the encoder (the push button). In the code, it is referred to as a button. It is D3 and it is tied to the bounce library.

Hope this clarifies things.

WannaDuino (author)gwfong2016-11-20

but can you show me your rotary?

i still have it not working like your picture, your seccond ground wire of the rotary, on the 2 pin side, i use it on D4.

thats not oke.

maybe it has to do with differend rotary type or somthing.

but i like to know that stuf. otherwise this keeps on my mind.

And that i used pin 7, yeah weird, but on 6 it did not work, so i changed the code to pin 7.

but i messured it, its not a faulty Nano or breadbord.

the code is doing it.

soyeah i want to know why, i like this stuf to know why and how.

i am an electrician

gwfong (author)WannaDuino2016-11-20

I don't have my stuff with me. I can tell you, though, that the rotary encoder I used is one that has a switch. That is, the encoder has 3 pins for measuring the left and right turning of the shaft and 2 pins for detecting when the shaft is pressed down (like a button or a momentary switch). When the shaft is pressed down a circuit is closed. And because it is a momentary switch, to prevent false signals, the circuit has been setup with a pull-down resistor. You can find more info on this at

As for using pin 6 vs pin 7 for the encoder, the encoder library from pjrc ( mentions that it can adapt to types of pins if the pins have some capabilities, specifically interrupts. My nano was a knock off. Maybe it's not to spec. Maybe the encoder library does or does not do with my nano different from yours.

If it was me, I'd build a circuit just to read the encoder signals (rotary and switch) and that's it. Find the pins that work and modify the code to use those pins.

WannaDuino (author)gwfong2016-11-20

Yes thanx,

i was thinking to also try with some other boards, i also got a knock off, got loads of them,

i will also use the UNO. just to be sure.

and some other types of rotary`s.

its just weird that a ground pin is on a un-specified pin ( D4 ) and then the whole thing works.


i like it!!!!

But this was a super fun build again, lots of problems, that al been solved. Super.

thanx for all your input and time to put this amazing 3D printed light on here.


WannaDuino (author)2016-11-19

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


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.


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


WannaDuino (author)WannaDuino2016-11-19

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 (author)2016-11-15

look is differend then the fritzing

WannaDuino (author)WannaDuino2016-11-19

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

gwfong (author)WannaDuino2016-11-18

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.

WannaDuino (author)gwfong2016-11-19

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!!!

WannaDuino made it! (author)2016-11-19

i now have some ( serial monitor info)

but still the ring is not going on.

also, the pinout is different than your sketch on the NANO i had to use D4 (only on breadboard, not changed in the sketch) to get serial monitor and to get the rotary to work, as a button and turning. and also the PIR is responding in the monitor serial.

but its behaving iradick not as it shut be i think. in sleep mode or when its of it sometimes not respond to get it running.

so let us see wat we together can do to get this AWESOME piece of art to work for everybody oke?

Did your ring light up on USB connected to the PC??(Both not working by me)

pleace make some pictures of your pcb and recheck every step.

Or i am the biggest dumb ass there is, or genius to see the flaws i dont know, but i hope its BOTH. Hahahaha

WannaDuino made it! (author)2016-11-19

it is still not good

there is now no 5Volt on the rotary ???

pleace check it your self, the NEW uploaded fritzing is not oke.and pleace DEFINE pin out 9 ??

can you send me good pictures of your build itself? so only your pcb and attachemends/ so i can see for myself also, and put it in mine backup foto files pleace,


gwfong (author)WannaDuino2016-11-19

I'm not entirely sure but I think that 5v in the spec diagram is really just suggesting that's source power. EncA and EncB will get that from the Arduino pins. A cleaner example of the setup is here There is no additional power. I do notice that the spec suggests using 10K ohm resistors. I did not do that. But maybe using them provides a cleaner signal.

As for Pin 9, that's the signal wire for the passive infrared sensor. In the center fritzing diagram above, it is the leftmost top yellow wire in the breadboard that goes to the center pin of the PIR. You should see that in the code as well. PirSleepDetection uses PIN_PIR which is defined as 9.

WannaDuino (author)2016-11-15

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?


gwfong (author)2016-11-11

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.

WannaDuino (author)2016-11-11

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.


gwfong (author)2016-11-04

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.

WannaDuino (author)gwfong2016-11-11

then you did not understand me,sory my english is bad,

you can make a simple usb cable your self or shorten 1 you already have,

and make the same conector on it FEMALE, so you can make a smal insert in your box for it, AND THEN ATTACH the new computer usb cable.

then you dont need to pull out al the stuf.

hope you now understand it,

the next time i make a picture if you dont get it. hahahaha

WannaDuino (author)2016-10-08

why not make a little extencion on the micro usb, then you can make a little hole in the desk holder to conect it direct, so you dont have to pul it out. and connect all direct.

i got loads of them and are also very cheap. you can get then on a smal pcb or use only an extencion micro usb female conector. if you need info or pictures i wil shoe you.

i want to make this also. so then you know that. i just order al of it on AliExpress.

and i orderd it DOUBLE hahaha, like i always do

WannaDuino (author)WannaDuino2016-10-08

OMG, i hate my keybord, and my bad english

WannaDuino (author)2016-10-08

i wil order also an 3d printer, whats the best budged now, banggood sells them for 300\400 euro i like them

About This Instructable




Bio: Just a guy looking to make cool things
More by gwfong:Copper Wire and Fused Glass ButterflyGoogly Eyes Minion ClockAuto-Off NeoPixel Articulated Reading Light
Add instructable to: