Intro
Well, I needed an eye catcher for the Maker Faire Ruhr 2018. Moving lights always gain the interest of people. Which includes me as well. The idea behind it: a LED stripe that changes color in response how close you get to it. The distance can be easily determined by a ultrasonic sensor. And with a Neopixel stripe I could easily change the color. But wait! With the Neopixels I can control each pixel individually. So instead of using one ultrasonic sensor, I'm using five. Each of the sensors triggers a different piece of the LED stripe.Problem
If you want to measure the time the sound takes to travel towards an object and back, you would usually use the puleIn-function. The problem is, that while the micro controller measures the time it does nothing else. So you would have to wait for the signal to return, before you can trigger another ultrasonic sensor. But we want to be able to operate several sensors simultaneously. I was about to imagine a proper algorithm, when I found out, that I wasn't the first to encounter this problem. And I'm not the first to find a solution for it. The library handles this issue.The Build
I've found a wooden plank from a slatted frame with a length of 135cm. Perfect! I'm using one meter in the middle for placing the Neopixel stripe and five ultrasonic sensors.The diameter of the ultrasonic sender and receiver tubes are close to 16mm. This is a drill size I had to purchase. I predrilled the holes with a 3mm drill, before using the 16mm one.
First I tried to glue the Neopixel stripe on to it, but that wouldn't hold. I fixed them with zip-ties.
I used an Arduino Nano as the controller, soldered a custom PCB and glued it on the back side of the lath.
I wanted the build to be robust. So I soldered wires from every sensor to the PCB. So that nothing will accidentally disconnect though the transport.
The Algorithm
The original design was that all LEDs were lit white when the maximum distance of three meters is detected. Technical speaking the values of all three colors are set to 254. The value of green and blue is now determined though the distance of an object to the sensors. Well it looked quite unspectacular, but it worked.Video
Wiring
The power from the Arduino will not be enough to power all sensors and the LED stripe. So you need to add an external power line (5V).Links
Arduino Nano @ amazonHC-SR04 Ultrasonic sensor @ amazon
Neopixels @ amazon
NewPing Libriary
Ultrasonic Lght Bar Code
No comments:
Post a Comment