Introduction: Bluetooth/Gyroscope/Accelerometer Controlled Lightball (with Individual Adjustable Leds in Each Side)
Finally (nearly topically) i made my personal lightball.
(A.k.a.: Another day in the FabLab Aachen)
Each side is enlighted individually with an intelligent LED (WS2812b, on a small breadboard) behind. A micro-controller (MSP430G2553, PDIP.) can use a gyroscope/accelerometer (MPU6050, GY-521 module) to change the colors, the which can itself be controlled via bluetooth (HC-06). There is space for a compass module (HMC5883L, GY-271 module) too.
Laser-cutter (cutting by hand is no fun)
Hot glue gun (and a bunch of sticks for it)
PCB mill (optional, a stripboard version works as well)
MSP430 launchpad (as programmer and for the micro-controller)
ca. 600*300mm acrylic for led backlight (0M200 SC)
(white) carton (seperating each side )
cables, 2.54mm connectors (female: 8, 6, 5, 3(*3), 2(*2) male: 3(*3), 2(*2)), resistor (4.7k(*2), 10k), capacitor (100nF(*7))
3* mignon cell holder for three batteries
32* WS2812B on a small board
HC-06 bluetooth module
GY-521 accelerometer/gyroscope module
(optional, unused) GY-271 compass module
Step 1: Cutting, Soldering
First the shapes for the sides of the ball (Football_Outside.svg) are cut out of the acrylic. Gladly i could use an lasercutter (epliog zing) in the fablab, doing that manually would be too much work.
The layout of the sides is done by another program (CutCad)
The parts for seperating each side in the inside are cut out of white carton (Football_Inside.svg) and glued together to pyramide structures (black lines are marked (folding edges), red lines are cutted).
12 pyramides with 5-edges and 20 pyramids with 6-edges are needed.
The Leds are soldered together with 3 wires between each other, connecting the voltage lines (5V and ground) and each output from one Led with the input of the next one. Mostly 5cm wire length is enough, but for first one (and maybe even the next five) longer wires are better for opening the housing for changing the batteries.
A longer wire, which leads to the first Led ends in a female 3-pin header to conenct to the microcontroller and battery.
Step 2: Construction
Now the construction can begin: Starting with a 5-edge acrylic, the next sides are connected in cycles. First fixate the sides provisoric with tape on the outside, and glue them together with a little bit hot glue. Then position the corresponding pyramid on the center of the side and later fill the gap between them with hot glue.
Ate the beginning i used instant adhesive and special acrylic glue, but the hot glue works out best.
The Leds are inserted in the small square on top of the pyramid and also fixated with hot glue. Coating the whole top layer with it will further stabilize the pyramids and isolate the solder pads. The led on the bottom should be the last led in the line (with the unconnected data output).
Working in cycles results in an simple mapping of the led line on the sides of the ball.
Don't forget to test the ball on the side, errors are easier to correct in each step now. Later everything is coated in glue and inaccessible.
Step 3: Finish Construction
The top 5 6-edges and the last 5-edge will remain loose - the batterie might not last forever (almost 2A maximal current) :-).
Here, the pyramids are just glued on top of each side, and again the led on top of it.
Again, don't forget testing - but don't connect a 9V batterie to the 3V programming line, that relieved the magic smoke from my first controller version.
Step 4: Smoothing the Edges
Now "sandpaper" (i used a proxxon and dremel with a corundom tool first, sandpaper later for finer work) the edges to smooth them. That's was the less funniest part of the whole building process. If i would do that again, i will try to make a holder for the sides, where i can cut each bevelled side with the laser cutter: There is a certain angle between 5-edge and six-edge and also another certain angle between 6-edges, which correspond to the angle with which the edge should "sandpapered" to get a smooth connection between two tiles.
Step 5: Electronics
The electronis uses 3 mignon cells in a row to provide 4.5V (and 3* parallel for more power), directly used as power source for the leds (instead of 5V), and 3.3V via 1117 fixed voltage regulator for the logic, buffered by the capacitors (only 100nF capacitors are used).
A MSP430G2553 is connected with the bluetooth module via RX/TX serial and to the gyroscope/accelerometer module via I2C (4.7k pullup resistor on each line) (and maybe later to a compas module). Don't forget a 10k pullup resistor on the micro-controllers reset input.
The logic input of the first Led is connected with pin 2.4 of the micro-controller, powered directly from the batterie.
Two wires can route the positive voltage to connector for a jumper one corner of the ball, to connect/disconnect the batterie power from the outside.
Step 6: Programming
Upload the Bluetooth.ino sketch on the MSP430G2553: I use a MSP430 launchpad as a programmer and the Energia-IDE. Either insert the micro-controller in the launchpad and program it there, or connect 3V, GND and the test and reset line (Spy-By-Wire-Interface) of the controller with the launchpad.
You need the WS2811Driver in the library folder - with a minor modification: The I2C connection uses pin 1.7, therefore we need to change in the ws2811.h file
#define WS2811_BITMASK BIT7
#define WS2811_PORTDIR P1DIR
#define WS2811_PORTOUT P1OUT
#define WS2811_BITMASK BIT4
#define WS2811_PORTDIR P2DIR
#define WS2811_PORTOUT P2OUT
Which allows to use pin 2.4.
The micro-controller expects commands like:
"I##CRGBT": Sets the led number ## (decimal value) to color red value R, green value G, blue value B (0...9)
"MRANDOMT": Random values for each led
"MACCELLT": Color change dependent on orientation (gravity vector)
"MROTATET": Color changes by gyroscope values (rotation)
"SrgbRGBT": 5edges and 6edges with different colors (rgb and RGB, each value from 0...9)
"POWER#TT": # (from 0...9) should be maximal allowed power consumation (0A...2A )
... replacing the 'T' at the end with a 'F' turns the mode of
These commands can be send e.g. from the serial window Arduino-IDE by connecting with the bluetooth module. Opening the LightballController with Processing allows to switch between the modes with a GUI.
(It searchs for serial port named "/dev/cu.HC-06-DevB" on my mac, for windows or linux other strings might be correct. Change line 38 to the correct string (all available ports are listed in the serial window below)).
Booth programs are just quick-and-dirty versions, but work well for now.
Step 7: Enjoy
Which means: Power up the ball and have Fun!