Interactive Handrail With Arduino

3,658

109

9

What is this project about ?

The concept is quite simple : a downlight that follows the steps of the user.

Now, I applied it to a handrail, but once you understand the principle, you will be able to put it pretty much anywhere.

My demarch was to mimic the move of a living creature, a kind of a "pet made of light" that will accompany you during your trip... in the staircase. In order to achieve that, a perfectly clean and fluid move of the light is absolutely necessary.

let's get started

Step 1: Body Sensing Principle

In order to get a smooth displacement of the lighting spot, you will need a clean, noiseless way to detect where the user is. If the readings are not perfectly stable, the light will jump around, even a little, breaking the "magic touch" of the device.


ultrasound and infrared ranging sensors ?

I first tried with ultrasound ranging sensors, several types (generic ones and also a more pricey from maxbotics), with very little success : It kind of works, but there is quite some physical limitation to this method. First, depending on the clothes you are wearing, the sensors works more or less well (especially the ultrasound ones). Second, for the IR ranging sensors, there is a max range and a min range at which the device will measure the distance, meaning that you will need a least 2 different models. Plus, either way, the readings are quite jumpy, and that is a real love killer for this project.

my way to go : a serie of DIY proximity sensors

Instead of trying to measure the distance from the user to one end of the handrail, I will put in place several contactless switches (16) along the handrail. You can do it by several methods, in my case I used infrared phototransistors : those are cheap, easy to understand and mount and very discrete. They will "see" the infrared reflected to them from the user. And to emit those infrared, you just have to put some infrared LEDs parallel to the phototransistors and pointing toward the user's body. You can use a infrared LED tape as well I suppose, it will be even easier to make!

16 ON/OFF contactless switches

As a arduino uno or nano doesn't have that much input, you will have to multiplex all the sensors data.

A multiplexer, despite a seemingly complicated name, does something very easy to understand : it will link a unique pin to another one (among 16). The path unlocked will depend on a binary code you will send to 4 other specifics pins.

those are the codes to send to the pins, in order (from pin 1 to pin 16):

0000, 0001,0010,0011,0100,0101,0110,0111,1000,1001,1010,1011,1100,1101,1110,1111

Yes, those are the numbers from 0 to 15 in binary.

All multiplexers work the same way, you can use the one you want, you just need a 16 channels.

Step 2: The Circuit

Material list

  • 1 arduino, I used Nano but any will do
  • 16 IR phototransistors (5mm)
  • 32 IR LEDs 5mm (use the same wavelength as you phototransistors) OR a IR LED tape
  • 1 multiplexer 16 channels (I used HF 4067)
  • 1 blank PCB
  • 1 power plug (or screw terminal)
  • 1 power supply (5V with a lot of amps : 7 or 8A )
  • a ribbon cord at least 16 wires.
  • 16x 27 ohms resistors (for the IR LEDS)
  • 16x 47 Kohms resistors (for the phototransistors)
  • a 6V1000uF capacitor
  • a LED addressable strip (APA102 or WS2812B)
  • wires...

Luckily, the PCB will be very simple. You just need to be aware of the order of the cables from the sensors to connect to the multiplexer. Using a rainbow ribbon cable will help a lot!

Then, from the output of the multiplexer, only one cable will be needed to connect to a arduino analog input (the pink one on the picture). And this is very neat!

Then the 4 control wires (the orange ones) will go from arduino pins 7,6,5 and 4 to the multiplexer control pins. Why 7,6,5 and 4? because we will be able to activates those pins in a single line of program, sending the binary code via the port manipulation method.

to read about port manipulation ( don't fear the word, it is pretty simple to understand) : https://www.arduino.cc/en/Reference/PortManipulati...

next you will need an addressable LED strip.

Any will do, I used APA102 (the good old WS2812B will work as well, and with just 3 pins). Link it up to the arduino, data pin (and clock pin if your LED strip needs it), and the power (5V). Last thing, adding a 1000uF to the power input of the strip is a wise decision.

Step 3: The Build

Obviously, the first thing you have to find is a rail of sort. I used a plank of flooring, 12mm thick Merbau. I just glued a slice of it on the upper part to make a thicker part for the hand to grip on.

The LED strip can be secured on a plastic extruded profile L shape on the bottom of the rail, all along.

Every sensor is just composed of 3 holes (5mm) for the LEDS to fit in (phototransistor in the middle, one IR LED on each side)

The PCB can be enclosed in a plastic box, or let free, just secured to the inner side of the handrail with screws.

Last, to fix the whole thing to the wall, I used L metal brackets that I screwed to a cubic wooden block I put on the wall with screws. This part is very specific to my home, you may have to be a little bit creative here.

Step 4: The Code

You can access it here : https://github.com/Benn25/handrail

I won't go in depth with it, just highlight a few things

Every sensor state, triggered (1) or not (0), will populate an array of 16 elements. Typically, the result will be something like 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0 if the user is close to the left end of the hand rail. now, imagine that the user moves just a bit toward the other end, now the result is 0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0. Yes, 2 sensors are triggered now because the user is between 2 sensors. The location of the light is computed every loop after reading all the sensors : the average position is where the light aims at. This method will virtually double the number of sensors increasing dramatically the density of the sensing apparatus, increasing at the same time the fluidity of the movement of the light!

Second thing : the dynamic of the movement is also computed every loop, this way I can track the speed of the displacement of the light, and it will also allows me to smooth down the movement of the light by a predefined factor to avoid any erratic jumping of the light.Thanks to those data, I have the speed of the user, and I can change the color of the light depending on this!

Last : the threshold at which the data from sensor will be interpreted as 1 or 0 is floating. meaning that the system adapts itself permanently to the level of environmental IR in the room. so you can have the sun directly hitting only a part of the rail, the system will auto correct after a while (around 5 sec).

Step 5: Going Further

want to add options?

I experimented with a folding model. I used a barometric sensor to change the light when nobody is detected according to the atmospheric pressure : high pressure = reddish, low = blue. The video is self explanatory.

If you have other idea, please do tell me in the comments !

one last thing : the way I chose to program the thing do NOT allow 2 people to use the device at the same time, the light will go between the 2 users (average position).

It is a choice, I did it this way by using the average position of the triggered sensor in order to reduce the noise in the move as much as possible, but you can totally make a 1 : 1 detection/enlightenment pattern where the triggered sensor will light up the corresponding area without any post process.

Arduino Contest 2019

Participated in the
Arduino Contest 2019

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • Pets Challenge

      Pets Challenge
    • 1 Hour Challenge

      1 Hour Challenge

    9 Discussions

    0
    None
    EricOwen1

    2 months ago

    1000µF capacitor of what voltage?
    I love this project. I am going to do it for the stairs in my 106 year old home.

    3 replies
    0
    None
    BenjaminD110EricOwen1

    Reply 2 months ago

    Those strips work with 5V, so any cap from 6V will do!

    0
    None
    EricOwen1BenjaminD110

    Reply 2 months ago

    Thanks for the reply. I read through the project info agan, did some research on the WS2812B. I already sourced a 1000µF 16v Electrolytic Capacitor. I forgot to come back and edit this. It was nice of you to follow up on my question. Have a nice weekend!

    0
    None
    smokie1969

    2 months ago

    Excellent instructable! Could you make it so that it lights up AHEAD of where you are stepping? That way you can see where your feet need to go, not just light up once you're there. Just a suggestion, but I've voted for you, good luck :)

    1 reply
    0
    None
    BenjaminD110smokie1969

    Reply 2 months ago

    Thanks!
    Yes this is a very pertinent idea, and I tried it during the development of this project, and it worked well. But on a 3~4m long staircase, it is too short and doesn't make sense very much. It was just weird, like if there was an error or something.
    But on a 10m rail, yes, this is a very good way to go for sure!

    0
    None
    HoltSi

    2 months ago

    Legit build man. Wish i could do this some time. It's the one i voted for becasue its the best looking one. Also very good instructable.
    1 reply
    0
    None
    BenjaminD110HoltSi

    Reply 2 months ago

    Oh thank you very much!
    You know, this project, at least the hardware part, is surprisingly easy to make. A lot of soldering, but still, the skills required are very basic. And for the software part, well, I give it up for free to the community ! :)

    0
    None
    audreyobscura

    2 months ago

    Your build is awesome thanks for sharing it!