cms 3 sensor report

14
Sensor User Manual TriColour LED By CHAU Tsz Ling (53554446), WAN Pui Yin (53444350), POON Man Ting (53553056) Sensor Name: Tri Color LED Cost per unit: $ 5 HKD Information URL to data sheet: http://cdn.sparkfun.com/datasheets/Components/LED/YSLR596AR3G4B5CC10.pdf

Upload: elainexchau

Post on 12-Nov-2015

26 views

Category:

Documents


0 download

DESCRIPTION

This is a sensor research on Tri-Color-LED.

TRANSCRIPT

  • SensorUserManualTriColourLED

    ByCHAUTszLing(53554446),WANPuiYin(53444350),POONManTing(53553056)

    SensorName:TriColorLEDCostperunit:$5HKDInformationURLtodatasheet:http://cdn.sparkfun.com/datasheets/Components/LED/YSLR596AR3G4B5CC10.pdf

  • GeneralInformationAboutLEDLEDstandsforLightEmittingDiode.Theyarediodesthataredesignedtogiveofflight.LEDsarespeciallybuiltintoroundedplasticbulbstomakethellightappearbrighterandmoreconcentrated.DifferentcolorsofLEDhavedifferentwavelengthwhichdeterminewhatcolorwillshowup.Forexample,whenthewavelengthisabout630640nanometers,itappearsasredcolor,while,whenwavelengthisabout465475nanometers,wecanseethelightasbluecolor.WhatdoesLEDdo?LEDtechnologyisaconvenient,energysavingandfastresponselightsource.Becauseofthesefeatures,itiscommonlyappliedindifferentdevicesinourdailylife,suchasroadmessagedisplay,trafficlight,flashlightetc.HowdoesLEDemitslight?Whenadiodeisforwardbiasedsothatelectronsandholesarezippingbackandforthacrossthejunction,they'reconstantlycombiningandwipingoneanotherout.Soonerorlater,afteranelectronmovesfromthentypeintotheptypesilicon,itwillcombinewithaholeanddisappear.Thatmakesanatomcompleteandmorestableanditgivesoffalittleburstofenergyintheformofatiny"packet"orphotonoflight.

  • AboutTriRGBLEDDiffused5mmtricolorLEDwithseparatered,greenandblueLEDchipsinside.3distinctcolorsinsidecandisplayseparatelyandindependentlycontrolledbytheuser.

    TheseareCommonCathodetypewhichmeansyouconnectonepinto5Vorsoandthentietheotherthreelegstogroundthrougharesistor.WecarryanduseCAmorethanCCbecausemultiLEDdriverchips(suchastheTLC5940/TLC5941)areoftendesignedexclusivelyforCAandcan'tbeusedwithCommonCathode.

    Afourleadarrangementistypicalwithonecommonlead(anodeorcathode)andanadditionalleadforeachcolor(RedGreenBlue).

  • Features&Specifiations

    ForwardVoltage:R:1.82.2G:3.03.4B:3.03.4 IV:R:50006000G:60007000B:25003000 XY/WLD:R:620625G:515520B:460465 LightColor:RGB Size:5mm EmittedColour:Red/Green/Blue Possiblenumbersofcoloremitted:256^3(256foreachRGB) Pinssequence:RED/CommonCathode(positiveterminal)/Green/Blue LensColor:Diffused LuminousIntensity:4000/8000/5000mcd ForwardVoltage(V):2.1~3.4 ViewAngle:60degree. easytoburnouttheLEDresistanceofafewhundredto1000ohm R:wavelength630640nmBrightness10001200mcdVoltage1.82.0V G:wavelength515512nmBrightness30005000mcdVoltage3.23.4V B:wavelength465475nmBrightness20003000mcdVoltage3.23.4V

  • Gettingittowork!

    Insertthe2LEDsfollowingthisdirection.Thelongestlegconnectedtoground.

  • Examplecode:/*triLEDplay*/intbutton1=13intval1intred1=9intgreen1=10intblue1=11intbutton2=2intval2intred2=3intgreen2=5intblue2=6intbright[6]={250,125,5,250,125,5}intfade[6]={5,5,5,5,5,5}booleanmode1=falsebooleanr1=falsebooleang1=falsebooleanb1=falsebooleanmode2=falsebooleanr2=falsebooleang2=falsebooleanb2=falseinttimeconstintpot=0 intpotVal=0 intpwmVal=0 voidsetup(){ pinMode(button1,INPUT) pinMode(red1,OUTPUT)pinMode(green1,OUTPUT)pinMode(blue1,OUTPUT)pinMode(button2,INPUT) pinMode(red2,OUTPUT)

  • pinMode(green2,OUTPUT)pinMode(blue2,OUTPUT)Serial.begin(9600)}voidloop(){val1=digitalRead(button1) val2=digitalRead(button2) potVal=analogRead(pot) pwmVal=map(potVal,0,1023,0,100)Serial.print("pot=") Serial.print(potVal) Serial.print("\tpwm=") Serial.println(pwmVal) //player1if(val1==1){if(!mode1){mode1=true}else{ mode1=falsebright[0]=250bright[1]=125bright[2]=5}}if(mode1){time=pwmVal*10if(!r1){bright[0]=250bright[1]=0bright[2]=0 r1=trueb1=false}elseif(r1&&!g1){

  • bright[0]=0bright[1]=250bright[2]=0g1=true}elseif(r1&&g1&&!b1){bright[0]=0bright[1]=0bright[2]=250 b1=truer1=falseg1=false}}else{time=pwmValfor(inti=0i
  • if(!r2){bright[3]=250bright[4]=0bright[5]=0 r2=trueb2=false}elseif(r2&&!g2){bright[3]=0bright[4]=250bright[5]=0g2=true}elseif(r2&&g2&&!b2){bright[3]=0bright[4]=0bright[5]=250 b2=truer2=falseg2=false}}else{time=pwmValfor(inti=3i
  • CodeinEnglish

    intbutton1,val1,red1,green1,blue1,button2,val2,red2,green2,blue2Setvariablesforeachbutton,buttonvalue(0/1,on/off),theRGBcolourandtheircorrespondingport,inordertoreadthedatafromtheswitchandcontroleachRGBcolourofeachLEDrespectively.

    intbright[6]={250,125,5,250,125,5}intfade[6]={5,5,5,5,5,5}inttimeSetarrayfrothebrightnessofeachLEDsRGBcoloursandalsogiveafadingvalue.Settimeforthechangeofdurationofdelay.

    booleanmode1,r1,g1,b1,mode2,r2,g2,b2Setbooleanforthemodeswitchtingofthelight.

    constintpot=0 intpotVal=0 intpwmVal=0 Settingofpotentiometre.TheeanalogpinA0willbeconnected,readingthedatathensaveinvariablepotVal,pwmValisthevariableformappinginthelaterpart.

    pinMode(button1,INPUT) pinMode(red1,OUTPUT)pinMode(green1,OUTPUT)pinMode(blue1,OUTPUT)pinMode(button2,INPUT) pinMode(red2,OUTPUT)pinMode(green2,OUTPUT)pinMode(blue2,OUTPUT)TellArduinothemodeofeachpin,whethertheyareusingasdatainputoroutput.

  • val1=digitalRead(button1) val2=digitalRead(button2) potVal=analogRead(pot) pwmVal=map(potVal,0,1023,0,100)Savethedataofthebuttonvalue(0/1,on/off)andpotentiometrevalueinvariables.Writteninvoidloop(),asthevalueshouldbereadthroughouttheprocess.AfterreadthepotVal,alsomappingthevaluefrom01023to0100forfurtheruse.

    Serial.print("pot=") Serial.print(potVal) Serial.print("\tpwm=") Serial.println(pwmVal)Printthepotentiomerevaluereadandthemappingresultintheserialmonitor.

    if(val1==1){if(!mode1){mode1=true}else{ mode1=falsebright[0]=250bright[1]=125bright[2]=5}}Afterreadingthevaluefromtheswitch,determinewhichmodetousebysimpleifelsestatement.Alsoresetthebrightnessofthelightafterusinganothermodeinordertogivethesameeffect.

    if(mode1){time=pwmVal*10if(!r1){bright[0]=250bright[1]=0

  • bright[2]=0r1=trueb1=false}elseif(r1&&!g1){bright[0]=0bright[1]=250bright[2]=0g1=true}elseif(r1&&g1&&!b1){bright[0]=0bright[1]=0bright[2]=250 b1=truer1=falseg1=false}}else...Foronmode,theLEDwillbbeshowingthecolourpatternred,green,blueinrythm.Nowsetthetimeofdelayaccordingtothevalueofthepotentiometre,buttimes10otherwisethechangeoflightwillbetoofast.Thethreeifelseifstatementistocontrolthecolourpattern.Afterredlighton,thengreenlight,andbluelight,thenloopagain....else{time=pwmValfor(inti=0i
  • Foroffmode,theLEDwillbefading,combiningdifferentcolours.Resetthetime,butnotmultiplying10thistimeasthatwillbetooslowforfadingeffect.AforloopisusedheretocallthearrayandtellseachRGBlighttofade.ThewholeifelsestatementwillberepeatedonceforthesameoperationofasecondLEDandsecondplayer.

    analogWrite(red1,bright[0])analogWrite(green1,bright[1])analogWrite(blue1,bright[2])analogWrite(red2,bright[3])analogWrite(green2,bright[4])analogWrite(blue2,bright[5])delay(time)Finallywritetheresultoutaccordingtothesituations,matchingeachlightwitheachbrightnessvalue.Delaythewholeprocessforaspecifictimedecidedbythevalueofpotentiometre.

  • Reference

    Chris,W.(2004,Aug11).DiodesandLEDs.Retrievedfromhttp://www.explainthatstuff.com/diodes.htmlAdafruit. DiffusedRGB(tricolor)LEDCommonAnode productdescription.Retrievedfromhttp://www.adafruit.com/products/159 ebay.(2015,Apr22).100x5mm4pinRGBTriColorDiffusedCommonCathodeLEDLampEmittingDiod.Retrievedfromhttp://www.ebay.com/itm/100x5mm4pinRGBTriColorDiffusedCommonCathodeLEDLampEmittingDiode/370946258804

    Sarah,L.(2013,Sep13).TheApplicationofLEDTechnologyinDailyLife.Retrievedfromhttp://www.lightingever.com/blog/theapplicationofledtechnologyindailylife/