arduino wearables: you light up my life-leon durivage

50
YOU LIGHT UP MY LIFE LEON DURIVAGE [email protected]

Upload: mobile-march

Post on 20-Nov-2014

484 views

Category:

Technology


2 download

DESCRIPTION

From Mobile March 2014-A quick look at creating Arduino-based wearable electronics, complete with design files. Learn the basics of building and programming an LED light strip built into a headband. The session covers programming, battery basics, sound activation, and construction techniques.

TRANSCRIPT

  • 1. Goals Light you up! Show a simple example Give you a place to start #3: LED Strip +5VDC #4: Battery Clock Data LM2596 Adjustable A0 D3 D 2 5 V G N D GND #1: Arduino Board#2: Microphone Module O U T V C C G N D #5: DC-DC Converter HEADBAND BATTERY PACK POWER CONVERTER CABLE (20) LEDs 1.25V

2. Agenda Why this project How its designed Where it could go 3. Why Skrillex was coming to town!!! What could we bring to the concert? LED Hats too easy to steal LED Shirts too ordinary LED Wristbands not easily seen LED Skirts not me! * LED Necklaces too easy to break Decided on headbands Easy to make Easy to hide Should be cheap * See Kristinas presentation at 2:15PM !! 4. Where to Get Started Three major components: Headband Battery Pack Power Converter Cable Needed four sets Might get broken, stolen or confiscated, so they had to be cheap. Maximize reuse of past projects Maximize reuse into future projects Budget was $200 and schedule was 2 months 5. Block Diagram #3: LED Strip +5VDC #4: Battery Clock Data LM2596 Adjustable A0 D3 D2 5V GND GND #1: Arduino Board#2: Microphone Module OUT VCC GND #5: DC-DC Converter HEADBAND BATTERY PACK POWER CONVERTER CABLE (20) LEDs 6. Major Design Decisions - 1 #3 LED Strip: decided to use a LPD8806-based LED Strip 1. LED Strip was chosen by convenience = I already had 2+ meters 2. Brightness set by LED Strip choice = 10mA to 15mA/LED 3. Number of LEDs set by head size = 20 LEDs Therefore: LED strip needs roughly 300mA at full brightness 4. System voltage set by LED Strip voltage, which = 5V 5. Arduino and microphone power considered negligible Therefore: Power needs are appr. 300mA x 5V = 1.5W #4 Battery: Li-ion battery pack (rechargeable, high energy-density), 18650 cell size (2600mAH, popular) in a 3-cell pre-assembled pack, 11.1V 6. Battery technology needed to be rechargeable (for reuse) 7. For power, battery needed to provide 1.5W for several hours 8. Battery voltage needed to be > (5V + minimum regulation voltage) 9. Battery needed to fit in pocket or purse 10.Pre-assembled packs, with built in protection for over-charge, low-voltage shutoff, short-circuit, etc. safer, less hassle Run Time SizePower 7. Major Design Decisions - 2 #5 DC-DC Converter: picked a LM2596 based DC-DC converter 11.Regulator needed to have an input of 11.1V and output needed to be 5V 12.Regulator needed to handle > 300mA, 500mA preferred 13.Regulator needed to be efficient to avoid heat and maximize run-time 14.Regulator needed to be small and light weight #1 Arduino: picked SparkFun Pro Micro, 5V version, based on size 15.Arduino voltage needed to be 5V to match LED Strip voltage 16.Arduino board size needed to be as thin as the LED strip ~ 0.5 to 0.7 17.Arduino board needed at least one analog input and two digital outputs #2 Microphone Module: AdaFruit P/N 1713 Electret Microphone Module 18.Microphone needed to have a built-in amplifier 19.Microphone needed to run on 5V 20.Microphone needed to have adjustable sensitivity 21.Microphone needed to be as thin as the LED Strip 22.Update: automatic gain control!! 8. #1: Arduino Board SparkFun Pro Micro Dimensions: 1.3 x 0.7" Features: ATmega32U4 - 5V/16MHz Supported by Arduino IDE Onboard Micro-USB 4 x 10-bit ADC pins 12 x Digital I/Os $20 9. #2: Microphone Module AdaFruit P/N 1713 Small Electret Microphone Built-in microphone amp Auto Gain Control (AGC) variable sensitivity! 5V Operation $8 10. #3: LED Strip Popular LPD8806 Controller IC Sold 32 to 52 LEDs per meter Approximately $20 to $30 per meter Available from multiple sources on eBay 11. #4: Battery Pack Li-ion for size, power density and recharging Pre-assembled w/ built-in protection circuitry 11.1V output can be regulated down to 5V 2600mAh size should last several hours Small enough to fit into a pocket or purse $30 12. #5: DC-DC Converter DC-DC Converter Module (LM2596 IC) Input: 4V to 35V (11.1V battery voltage) Output: 1.5V to 30V - adjusted to 5V Current: 3A (max) - can handle the estimated 250mA to 300mA Small and efficient 80% to 90% Multiple sources Appr. $1.25 ea. 13. Rough Costs 1) Arduino = $20.00 2) Microphone = $8.00 3) LED Strip = $11.50 4) DC-DC Converter = $1.25 5) Battery Pack = $30.00 6) Wiring & Plugs = $6.00 7) Headband = $1.25 8) Misc = $1.00 Total cost per Headband approximately: $80 each Plus: Charger = $18.00 Decided to only build 3 to stick close to budget. 14. General Construction See Appendix Battery Pack Power Convertor Cable Headband ~1 to 2 hours each 15. Software - 1 /************************************************************************/ /* Headband01: LPD8806-based RGB LED Modules in a strip using audio input /* lights up all LEDs in a rainbow of color, with variable brightness /************************************************************************/ #include "LPD8806.h" //the color strip library #include "SPI.h" //the communication library for strip #define NLEDS 20 //Number of RGB LEDs in strand #define AVERAGECOUNT 32 //the number of audio samples to average #define AUDIO 0 //the analog input channel #define OFFSET 255 //the DC offset of the microphone module // Chose 2 pins for output; can be any valid output pins: #define DATAPIN 2 //connect to the Data In pad on the LED strip #define CLOCKPIN 3 //connect to the clock pad on the strip // First parameter is the number of LEDs in the strand. Next two // parameters are SPI data and clock pins: LPD8806 strip = LPD8806(NLEDS, DATAPIN, CLOCKPIN); struct RGB { // a structure to hold the color of a pixel byte r; byte g; byte b; }; 16. Software - 2 /************************************************************************/ /* setup: the initialization code - executes once on reset (power up) /************************************************************************/ void setup() { strip.begin(); // Initialize the LED strip strip.show(); // Update the strip; to start they are all 'off' } 17. Software - 3 /************************************************************************/ /* loop: the main program - executes forever /************************************************************************/ void loop() { int audio = 0; // storage for the averaged reading for (int i=0; i < 220; i++){ // get an averaged audio sample from the mic then // draw a rainbow of colors out from the middle rainbowMiddle(NLEDS, averageDetect(AUDIO), i); } for (int i=219; i > 0; i--){ rainbowMiddle(NLEDS, averageDetect(AUDIO), i); } } 18. Software - 4 /************************************************************************/ /* averageDetect: Get the average analog voltage on the analog input pin /************************************************************************/ int averageDetect(int analogIn){ int averageValue = 0; // initialize average value long int sum = 0; // initial register to hold the sum int sensorValue = 0; // analog input sample (A/D= 0 to 1023, 0 - 5V) // read AVERAGECOUNT analog values and find the average for (int i=0; i < AVERAGECOUNT; i++){ // read the analog voltage (range is 0 to 1024) // subtract the DC offset of the module and then sum // the absolute value sensorValue = analogRead(analogIn) - OFFSET; sum = sum + abs(sensorValue); // } averageValue = (sum / AVERAGECOUNT) ; //calculate the average return (averageValue); } 1.25V 19. Software - 5 /************************************************************************/ /* rainbowMiddle: draws lines from the middle of the strip outward /************************************************************************/ int rainbowMiddle(int peak, int brightness, byte shift){ struct RGB color = {0,0,0}; // the color of a single pixel int j = NLEDS / 2; // middle of the strip brightness = 0xFF / brightness; //Color the strip from the middle out to the ends // if the position along the strip is less than the peak, color the pixel // else, turn off all the pixels above the peak value for (int i = 0; i < j; i++){ // going to mirror the colors if (i < peak){ // get the color for this position (input range 0 to 384) color = Wheel((i * 384 / NLEDS + shift) % 384); strip.setPixelColor(j - i-1, color.r / brightness, color.b / brightness, color.g / brightness); strip.setPixelColor(j + i, color.r / brightness, color.b / brightness, color.g / brightness); } else { strip.setPixelColor(j - i-1, 0, 0, 0); strip.setPixelColor(j + i, 0, 0, 0); } } strip.show(); //show the new colors - takes ~ 4.66 msec on the Uno } 20. Software - 6 /************************************************************************/ /* Wheel: Input a value 0 to 384 to get an RGB value from a color wheel /* The colors transition from r > g > b and back to r /************************************************************************/ struct RGB Wheel(uint16_t WheelPos){ struct RGB color = {0,0,0}; // storage to calculate the color switch(WheelPos / 128){ case 0: color.r = 127 - WheelPos % 128; // Red down color.g = WheelPos % 128; // Green up color.b = 0; // Blue off break; case 1: color.g = 127 - WheelPos % 128; // Green down color.b = WheelPos % 128; // Blue up color.r = 0; // Red off break; case 2: color.b = 127 - WheelPos % 128; // Blue down color.r = WheelPos % 128; // Red up color.g = 0; // Green off break; } return color; } 21. DEMO 22. Where Could It Go? More LEDS!!! Cheaper, smaller electronics Cheaper, smaller battery Washable Add light modes Add spectrum analysis Add light sensor Bluetooth to phone Get color data from soundboard Send individual color data Run Time SizePower 23. Questions? Thank you for your time!! Files at: https://www.dropbox.com/sh/kmfop133g57 8815/LjwEI3AlPT 24. Appendix - General Construction Assemble Battery Pack Assemble Power Convertor Cable Assemble Headband 25. Battery Pack Step 1 Assembled Battery Pack using (3) 18650 3.7V 2600mAh cells Built-in over-charge and over-discharge protection circuitry Comes w/ 6 wires From All-Battery Center on eBay Roughly $30 each 26. Battery Pack Step 2 Solder Deans-style to the battery wires Use Female socket for battery Note polarity! Be careful not to short battery wires when soldering Use shrink tubing to protect against accidental shorts 27. Battery Pack Step 3 Finished Battery Pack Charge with compatible charger eBay: Tenergy TLP-2000 Li-Ion Charger Solder Male Deans Plug to Charger output leads 28. Power Converter Cable Converts Battery voltage to 5V Battery Input 5V Plug To Headband DC-DC Converter Module 3 Foot Cable 29. Power Converter Cable Step 1 Buy a 1-meter 5.5mm/2.1mm Male-Female Power Cable and cut into two sections Female socket side = appr. 6 inches Male plug side = remaining length appr 3 feet 5V Plug From Power Converter 5V Socket From Headband 30. Power Converter Cable Step 2 Solder 6-inch 22AWG Red/Black wires to input side of the module Solder the 3-foot Male Power Cable to the output side Note the color and polarity of the internal wires Adjust trimpot to get 5V on the output 31. Power Converter Cable Step 3 Solder Red/Black wires from input side to Male Deans Plug Be sure to use Shrink tubing Note polarity Battery Power Converter 32. Power Converter Cable Step 4 Fold both wires back roughly 0.5 inches from the module edge Secure with tie-wraps to form strain reliefs Secure cables to module with tie wrap 33. Power Converter Cable Step 5 Use 1.0-inch to 1.25-inch Shrink tubing over the entire module Slightly heat the ends of the tubing and pull tight with tie-wraps 34. Headband 35. Headband Step 1 Cut the LPD8809 strip to 20 LEDs Cut along the lines Note the direction of the arrows indicates which is the input end 36. Headband Step 2 Solder Data (DAI) and Clock (CLK) lines to thin flexible wires (26 32 AWG) roughly 3-inches Solder heavier gauge wire to 5V and GND (22 AWG) 37. Headband Step 3 Solder Data to I/O-2 on the Arduino Solder Clock to I/O-3 on the Arduino Solder Red 5V wire to the Arduino 5V pin Solder Black GND to the GND on the Arduino Secure wiring with tie-wrap 38. Headband Step 4 Solder the 6-inch Female Power cable to the Arduinos 5V and GND confirm polarity! Solder 22AWG wires from Arduino to the Microphone Module Blue = Mic-OUT to Arduino A0 (Analog 0) Black = GND Red = 5V Use tie-wrap 39. Headband Step 5 Wiring complete! Inspect solder joints Confirm connections with ohmmeter before applying power Confirm everything with test code! Note: picture shows older microphone module 40. Headband Step 6 Adjust the Microphone Gain to lowest level Solder a short jumper from Gain to Vdd 41. Headband Step 7 Hot Melt Glue can be used to secure wiring 42. Headband Step 8 Create supporting plastic band from available material 1 x 19.5 Thin plastic Must be flexible 43. Headband - Step 9 Attach one side of self-adhesive Velcro to back Trim other end to aid in threading into headband 44. Headband - Step 10 Tape LED Strip to plastic support strip Dont block LEDs 45. Headband Step 11 Tape Arduino a bit more securely to protect wiring Note: picture shows older microphone module 46. Headband Step 12 If there is a logo twist the Cotton headband around so the outside is plain Cut a 1 slot in the headband Attached the other side of self-adhesive Velcro to the inside of the headband on either side of the slot Carefully thread the assembly into the headband 47. Headband Step 14 Attach half of the Velcro on the module to one side of the slot in the headband Route the power cable out the slot Insert the rest of the module on the inside of the headband 48. Headband Step 15 Finished installation of the electronics in the headband 49. Headband Step 16 Done!