Motion Sensitive Light Cap
Impress your friends with a cap with an illuminated brim which changes colour when you tilt your head and changes brightness when you move.
Things used in this project
Hand tools and fabrication machines
Soldering iron (generic)
Hot glue gun (generic)
Crimp Tool, Heavy-Duty
The light hat is fully wearable untethered tech to use out and about and impress your friends and colleagues. It's a baseball cap with 5 RGB LEDs mounted in the brim to illuminate your face and workspace. But the key thing which sets this apart is that it is motion controlled. Using a motion sensor (MPU6050) the cap is able to detect when you are turning your head, how fast you are turning and also what angle you are tilting your head forward and to the side. Using this information it changes the colour of the lights, how bright they are and also adds a gentle breathing effect to them for good measure.
When you tilt forward and backwards the colour changes.
The faster you rotate your head in any direction the brighter the lights get.
As you tilt your head to one side the lights start to pulse in a gentle breathing rhythm.
Put it on and away you go...
The hat is a standard baseball cap which I have adapted with the electronics. The It's Arduino Nano based with an MPU6050 attached directly to it. The Lights are also attached directly to the Nano as is the battery connector. It's powered by a small 3.8V LIHV battery and wrapped in rubber bands to protect it and the wiring. The lights are wrapped around a piece of material and fixed to the brim using rubber bands and some hot glue. Double sided foam tape is used to create distinct segments for each LED and to hold a plastic diffuser in place covering the brim. The electronics and battery are then affixed to the front side of the cap.
At it's core the software waits for a new MotionSensor reading, calculates the rotational delta, the tilt of the head forward and to the side and uses these to set the Hue, Saturation and Value according to crude heuristics. It may be of interest that it does this using the MPU6050 native output, Quaternions, as far as possible rather than angles.
The LightCap also allows the generation and storage of MPU6050 calibration values in EEPROM and also rotation offset values in EEPROM. This removes the need to modify the sketch for each deployment. You can just connect to a Serial interface and configure it using the commands defined in the sketch.
The code also includes a 'Signal Generator' creating the breathing effect which is used to modify the lights. This uses a set of data points to define the waveform which are used with interpolation to create a smooth result with a variable period.
The code builds on an asynchronous Arduino framework I have developed called SweetMaker. This provides a simple event driven callback API notifying applications of events of interest. Events might be a new MotionSensor reading or a regular 'tick' event to say 1s has passed. The framework also provides the Signal Generator code and other helpful functions such as a Performance Monitor.
The MotionSensor library used is part of the SweetMaker family and provides 'Quaternion first' handling of readings to avoid the need for trigonometric functions as far as possible.
Also the hardware configuration and associated software is also part of the SweetMaker family and goes by the name of StrawberryString. A StrawberryString can be used for a LightCap and for many other applications.
This isn't the time to talk more about SweetMaker but I hope to follow this up with more SweetMaker related posts.
Quick Sketch to show how it connects up.
This Arduino Library includes code for controlling a StrawberryString and in the examples 'LightCap.ino'. It needs to be used in conjunction with SweetMaker/core and SweetMaker/MotionSensor