led light stick - cornell universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... ·...

7
LED Light Stick ECE 4999 Independent Study Summer 2016 Author: Stefano Barbier Advisor: Bruce Land

Upload: others

Post on 22-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

LEDLightStickECE4999IndependentStudy

Summer2016Author:StefanoBarbierAdvisor:BruceLand

Page 2: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

2

Introduction: Aonemeterlongstripof60neo-pixelsisconnectedtoanArduinoUnoandaportablebatterytorecreateimageswithalongexposurecamera.ImagescaneitherbedownloadedonlineorcreatedinAdobePhotoshop.Imagesarecompressedto60pixelshigh,whilemaintainingproportionalhorizontaldimensions,andexportedasaJPEG.ThisJPEGisreadinaJavaprogram(writteninEclipseNeon),whichexportsatextfilewitheachpixel’scolorasoneelementinalonglist.EachpixelintheJPEGimageisconvertedtoits’binaryRGBrepresentationandthencolormappedtotherainbowcolors(ROYGBIV).TheoutputtedlistiscopyandpastedintoanArduinoIDEscriptandsavedinflashmemory.Thescriptreadsthelistin60elementchunksandflashesthemtotheLEDstick.Acameraonatripodissetupwithanexposuretimeofaroundtenseconds.AuserwalksacrosstheframewhileholdinguptheLEDstickduringthedurationoftheexposure.ExampleImages:

Page 3: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

3

Page 4: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

4

Materials:

• 1onemeterlongflatwoodenstick(HomeDepot)• 1neopixelstrip(Adafruit.com)• 1ArduinoUno• Electricalwires• Electricaltape• 2Zipties• 1portableiPhonebattery

Construction:

1. PeeloffthebackoftheLEDstripandattachtothewoodstickwiththeprovided3Madhesive.

2. Reinforcetopandbottombywrappingwithaziptie.3. AttachtheArduinoUnotothebackofthewoodenstrip.4. ConnectLEDdatalinetoadigitalportontheArduinoUno.5. ConnectLEDgroundandpowertogroundand5VontheArduinoUno.6. Attachportablebatterytowoodstick.7. ConnectportablebatterytotheArduinoviathepowerjack.

Page 5: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

5

HowtotakeaPhoto:

1. SetupaDSLRonatripodandusetestshotstofinda10secondexposurethatisverydarkbutlightenoughtojustseetheforegroundandbackground.

2. DownloadtheArduinoscripttotheArduinoUno,unplugfromthecomputerandplugintotheportablebattery.

3. Setthecameraonatensecondtimerandpresstheshutterbutton.4. Listentothetenbeepsfromthecameraandbetweenthe8thand9thbeep

presstherestbuttonontheArduino.5. Atthesametimebeginwalkingacrosstheframeperpendiculartothe

directionthecameraispointingwhileholdinguptheLEDstickandmaintainaconstantvelocity,height,anddistancefromthecamera.

6. InPhotoshopraisetheshadowsanddarkssothatthebackgroundismorevisible.

ImageProcessing: ImageschosenfromtheInternetmustbesomewhatsimpleindesignsowhencompressedto60pixelshighthegraphicisstillrecognizableandalsomusthaveauniformbackgroundcolor.InAdobePhotoshopReplaceColorisusedtochangethebackgroundcolortoblack(bydefaulttheLEDstickdoesnotturnonapixelwhenitissentblackcolor).Theimageisthencompressedto60pixelsinheightwhilemaintainingproportions.ThemaximumwidththeArduinocanstoreisabout180pixels.TheimageisthensavedasaJPEGinthehighestquality. InJavatheJPEGisreadandeachpixelisconvertedtoitsbinaryrepresentation.ThebinaryrepresentationisthenconvertedtoaninstanceoftheclassColors,whichhasthreeintegerfieldsforR,G,andB.Thedistanceformulaisusedtodeterminewhichcolorfromtherainbowcolors(ROGYBIV)eachpixelisclosestto.TheR,G,andBareusedasx,y,andzwouldbewhencalculatingthedistancebetweentwopoints.Thescriptthencreatesalistwhereeachelementisan

Page 6: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

6

integerthatrepresentseachnewpixel’srainbowcolor.Thelistreadsfromthetoprightoftheimage,downthefirstlefthandcolumntothebottomandthenjumpsuptothetopofthesecondcolumnetc…Thescriptthenexportsatextfilewiththislist.

TheusercopyandpastesthislistintotheArduinoscript.Thislistmustbestoredintheflashmemory(32kbytes),astheSRAMisonly2kbytes.AnLEDlibrarymustbedownloadedfromthemanufacturer’swebsiteandaddedtotheArduinoprogramfiles.ThisprovidesfunctionssuchassetPixelColor,whichallowsyoutodirectlyaddresseachpixelwithaknownRGBvalue.InloopthescriptreadsonecolumnatatimeandtranslateseachintegerbacktoitscolorRGBrepresentation.Thesethreeintegersareusedtoseteachpixel.Attheendofsettingtheentirecolumnthescriptsaysstrip.show(),whichturnstheLEDstriponwithalltheassignedcolors.Attheendofthedisplaythescriptdelays30millisecondsandthenreturnstothelistandsetsthesecondcolumn(pixels60-119).AttheendofthelisttheLEDstripturnsoff.

Page 7: LED Light Stick - Cornell Universitypeople.ece.cornell.edu/land/courses/eceprojectsland/... · 2016. 8. 23. · 1. Set up a DSLR on a tripod and use test shots to find a 10 second

7