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

Post on 22-Aug-2020

0 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

LEDLightStickECE4999IndependentStudy

Summer2016Author:StefanoBarbierAdvisor:BruceLand

2

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

3

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.

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

6

integerthatrepresentseachnewpixel’srainbowcolor.Thelistreadsfromthetoprightoftheimage,downthefirstlefthandcolumntothebottomandthenjumpsuptothetopofthesecondcolumnetc…Thescriptthenexportsatextfilewiththislist.

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

7

top related