LattePanda DFR0418 User manual

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 1/58
CONTENTS
GettingStartedwithLattePanda
PoweronyourLattePanda
Connectwithyourperipheraldevice
ConnecttoWi-Fi
Connectwith7“DisplayandTouchPanelOverlay
Software&OperatingSystems
HowtosetupaVNCserverontheLattePandausingTightVNC
Hardware&Accessories
InputsandOutputs
HowtoaccesspinoutsfromVisualStudio
ProjectExamples
Node-RED
TurnaLattePandaintoa3DPrintServerUsingOctoprint
FaceDetectionusingOpenCV
Troubleshooting&FAQs
HowdoIknowLattePandaison?
HowdoIre-installLattePandaWindowssystem?
WhatBootMethodDoesLattePandaUse?
CommonAdaptersandUSBcablerecommendations
GETTING STARTED
Power on your LattePanda
TheLattePandaispoweredthroughthemicroUSBport.AnystandardUSBadapter(suchasacellphonewallcharger)with
atleast2AofcurrentcanbeusedasapowersupplyfortheLattePanda.Apoweradapterwillnotbebundledwiththe
board,butyoumaygetonefromouronlinestoreoranyelectronicsretailer.
Note:CheckyourpoweradapterandUSBcableconnectionbeforeuse.Insufficientorunstablecurrentmaypreventyour
LattePandafrominitializing.
Here’sourlistofrecommendedpoweradaptersandcables
WhenyouhaveanadapterandmicroUSBcableready,followtheinstructionsbelowtogetstartedwithyourLattePanda.
1.PlugtheUSBintotheUSBpoweradapter,andthemicroUSBintothemicroUSBportoftheLattePanda(ThemicroUSB
portislocatednexttotheSDcardsocket).
IfyouneedIPSdisplayandtouchpanel,pleaseplugitfirst
Welcome

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 2/58
2.Whenpluggedin,youshouldseetheredLEDindicatorlightsupontheundersideoftheboard.Thismeansthatthe
LattePandaisinitializing.WaitpatientlyforafewsecondsuntiltheLEDgoesout.
3.WhentheLEDturnsoff,pressandholdthepowerbuttonforonesecondtoturntheLattePandaon.Youshouldseethe
LEDlightsupagain

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 3/58
Connect with your peripheral device
LattePandaiscompatiblewithawiderangeofperipheraldevices.
YoumayconnectanyUSBsupporteddevices,suchflashdrives,mouseandkeyboard,orawebcamtoUSB3.0and2.0ports.
TheSDcardsocketsupportsextrastoragefromaminiSDcard.YoumayalsoconnecttheLattePandatoanexternal
speakerdevicethroughits3.5mmaudiojack.
TheLattePanda’sArduinocompatibleco-processorwithplugandplayheadersandGPIOpinssupportsstandard5V
sensorsandactuatorsthatenableittointeractwiththephysicalworld.

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 4/58
Connect to Wi-Fi
1.InstalltheWi-Fiantennabypluggingtheroundshapedendintothesocketlabelled“ANT”locatednexttotheGPIOpins
ontheboard.
2.InWindowsselectaWi-FiconnectionbyclickingtheWi-Fiiconinthesystemtrayatthebottomrightofthescreen.Follow
thewizardtosetupaconnection.
Note:AweakWi-FisignalmaypreventaWi-Ficonnectionbeingestablished.Checktheantennaisconnectedproperlyto
theboardandmakesurethataWi-Finetworkisavailable.
Connect with 7“ Display and Touch Panel Overlay

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 5/58
Note:PleaseconnectitwithLattePandaBEFOREpower-on.AndmakesuretheGoldenFingerfacetherightside.
ThecontactsonFPCaresocompactandinorder.Pleasebecarefulthatanydislocationconnectionmaycausethe
LattePandashortcircuitandtheIPSdisplayabnormallikeghostingorflicker.
1.Liftuptheactuator.Usethumborindexfingermightbeeasier.

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 6/58
2.InsertdisplayFPCin.
PlaceGoldenFingersidedown!
Note:TheFPCmustbefullyinsertedintheconnector.Ifnotfullyinserted,theactuatorwillnotcloseproperly.Shouldthis
bethecase,liftuptheactuatorandrepeattheprocess(startingwithStep1above)
3.Rotatedowntheactuatoruntilfirmlyclosed.
4.InserttheFPCoftouchpanelin
Sameasthedisplay.PlacetheGoldenFingersidedowntoo.

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 7/58
Software & Operating Systems
Setting up a VNC server on the LattePanda using TightVNC
INTRODUCTION
InthistutorialIwilldemonstratehowtoinstallaVNCserviceonyourLattePandausingWindows.Thiswillenableyouto
accesstheGUIofWindowsrunningonyourLattePandafromadifferentPConyourlocalnetwork.IwilluseTightVNC,a
freeandeasytosetupservice.
VNCstandsfor“VirtualNetworkComputing”.Itisawayoftransmittingthekeyboardandmouseeventsofonecomputer
toanother-inotherwordsusingonecomputertoremotecontrolanother.Thisisusefulbecauseyoumightnothaveextra
monitors,keyboardsormicelyingaround–usingaVNCserviceenablesyoutoaccessseveralcomputersonyourlocal
networkusingjustonecomputer,monitor,keyboardandmouse.Youmightalsohaveaheadlessserversetupwhich
doesn’trequireconstantlyattachedperipherals.SettingupaVNCserveronyourheadlessserverisahandywayto
interfacewithaGUIifandwhenyouneedit.
Let’sgetstarted:
STEP 1 - INSTALLATION
1.DownloadandinstallTightVNCforWindowsonyourLattePanda.Choose32-bitor64-bitdependingonyoursystem
architecture.
(LattePandaStandardis32-bit,LattePandaEnhancedis64-bit)

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 8/58
Download(http://www.tightvnc.com/download.php)
2.End-UserLicenceAgreement
Acceptthelicenceagreementandclicknext
3.ChooseSetupType
TypicalinstallationwillinstallbothTightVNCserverandTightVNCvieweronyourLattePanda
Custominstallationallowsyoutoselectwhichelementstoinstall.Reallyallweneedistheserver,unlessyouwouldlike

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 9/58
tobeabletoviewotherPCsonyournetworkthroughtheLattePanda,inwhichcaseyouwillneedthevieweraswell.
Forthistutorialwewilljustdothetypicalinstall.

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 10/58
4.SelectAdditionalTasks
Checkalltheboxes

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 11/58
5.ReadytoInstallTightVNC
ClickInstalltobegin!

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 12/58
6.TightVNCServer:SetPasswords
Password-basedA
Atthispointitiswisetosetapasswordforremoteaccess.Pointtheradiobuttontowards“Requirepassword-based
authentication”andchooseapassword.Retypeitinthefollowingbox.
Ihavesetthepasswordas“lattepan”(asthepasswordcan’tbelongerthan8characters)
7.AdministrativePassword
Thisisnotstrictlynecessary.InthistutorialIwillnotsetanadministrativepassword,butyoumayifyouwish.Ifyouset
apasswordforthisyouwillhavetoenteritbeforechanginganyconfigurationsettings.
Whenyouarehappywithyoursettings,click“OK”.Click“Finish”toexitthesetupwizard.
STEP 2 - CONFIGURATION

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 13/58
Youshouldnowseeanewiconinyoursystemtray.(Ifyoudon’t,tryloggingoutandloggingbackintoyourPC).
HereyoucanseetheIPaddressyourPCison.
Doubleclickittobringuptheserviceconfigurationwindow.Thedefaultsettingsshouldbefineforourpurposes.
Next,youwillneedtogoontothecomputeryouwouldliketocontroltheLattePandawithandusingthesameinstallation
package,installTightVNCviewer.
WhenyouhavesuccessfullyinstalledTightVNCviewer,checkthatyouareonthesamenetworkasyourLattePanda,
otherwiseitwillnotwork!
WhenyouarecertainthatyourcomputerandtheLattePandaareonthesamelocalnetwork,proceedtostep3
STEP 3 - TESTING

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 14/58
OpenTightVNCViewer.AwindowwillappearforanewTightVNCConnection.Atthispoint,youneedtoinputtheIP
addressofyourLattePanda.
Tip:AquickwayoffindingthisisifyouhoveroverthesystemtrayTightVNCicononyourLattePanda.Ahintwillpopup
with“TightVNCService-”Youcouldalsogointoyourroutercontrolinterfaceandlookforattacheddevices.
ThenextstepistoinputthisIPaddressintheNewTightVNCConnectionWindow,followedbytheportnumberyousetin
theservicesettings.Thedefaultisport5900.
<ipaddressofLattePanda>:<portnumber>
e.g.192.168.2.60:5900
Clickconnect.Ifallgoeswellyouwillbepromptedwithapasswordinput.Inputthepasswordyousetearlier.Mypassword
was“lattepan”.Pressenter.
YouwillbegreetedbyawindowcontainingyourLattePanda’sGUI!Youmaynowcontrolitremotely!

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 15/58
ThisconcludestheLattePandaVNCtutorial.Ifyouhaveanyquestionsorcommentspleaseletusknowintheforum.Ihope
thishasbeenofhelptoyou.
Hardware & Accessories
Inputs and Outputs
InthisarticlewewilldiscusstheimagesoftheLattepanda.Belowisabasicdiagramthatdisplaysallthepins:

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 16/58
PinoutsinareaU1areassignedtotheX-Z8300core.
PinoutsinareaU2areassignedtotheATmega32u4core.
Eachofthe20digitalpins(A0-A5,D0-D13)inareaU2canbeusedasaninputoroutput,eachoperatingat5volts.Each
pincanoutputorreceive40mAandeachhasaninternalpull-upresistor(disconnectedbydefault)of20-50kohm.
Caution:Exceeding40mAonanyI/OpinmaycausepermanentdamagetotheATmega32u4.
Somepinshavespecializedfunctions:
AnalogInputs:A0-A5,A6-A11(onD4,D6,D8,D9,D10,andD12).TheLattePandahas12analoginputs,labeledA0through
A11,allofwhichcanalsobeusedasdigitalI/O.Eachpinhasa10bitresolution(i.e.1024differentvalues).Bydefaultthey
measurefromgroundto5volts.
Serial:D0(RX)andD1(TX).Usedtoreceive(RX)andtransmit(TX)TTLserialdata.
ExternalInterrupts:D3(interrupt0),D2(interrupt1),D0(interrupt2),D1(interrupt3)andD7(interrupt4).Thesepinscan
beconfiguredtotriggeraninterruptonalowvalue,arisingorfallingedge,orachangeinvalue.
PWM:D3,D5,D6,D9,D10,andD13provide8-bitPWMoutput.
SPI:D16(MOSI),D14(MISO),D15(SCK).
LED:D13Thereisabuilt-inLEDdrivenbydigitalpin13.Whenthepin'sval
TWI:D2(SDA),D3(SCL).
Otherpinsontheboard:
Reset:
BringthislineLOWtoresetthemicrocontroller.Typicallyusedtoaddaresetbuttontoshieldswhichblocktheoneonthe
board.
How to access pinouts from Visual Studio
LATTEPANDA.FIRMATA
LattePanda.Firmata(https://github.com/LattePandaTeam/LattePanda-Development-
Support/tree/master/LattePandaFirmata)isanopen-sourceFirmatalibraryprovidedbyLattePanda,whichissuitablefor
WindowsappsdevelopedinVisualStudio.ThisclassallowsyoutocontrolArduinoGPIOfromWindowsapps,withfeatures
including:
●Readingandwritingtodigitalpins
●Readinganaloginputs
●Controllingservomotors
●SendingdatatodevicesandreceivingdataformdevicesthroughtheI2CBus
3 STEPS TO YOUR REMOTE ARDUINO PROJECT
1.SetupyourPC
2.SetuptheArduino(Itispre-installed,unlessyouchangedtheArduinoprogram)
3.Createaprojectorusethesampleproject(http://www.lattepanda.com/wp-
content/uploads/2016/02/blinkYourBoard.zip)
FUNCTIONALITY
CONSTRUCTOR
publicArduino();
publicArduino(stringserialPortName,Int32baudRate,boolautoStart,intdelay);
publicArduino(stringserialPortName);
publicArduino(stringserialPortName,Int32baudRate);
Therearefourdifferentconstructors,youcanchoosetheproperonedependingonyourneeds
Parameters
serialPortName: SpecifyserialportnamewhichyoucanfindintheDeviceManager
baudRate: Itspecifiestheserialportspeed,thevaluemustbethesameasArduinoFirmata.Thedefaultvalueis57600.

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 17/58
autoStart: ConnecttheArduinoautomaticallywhenitistrue.Defaultvalue:True
delay: Setthemaximumintervalinsecondsofserialconnectiontimeout.Defaulttime:8Seconds
CONFIGURATION
publicvoidpinMode(intpin,bytemode);
Setsthemodeofthespecifiedpinasyouwish
Parameters
pin: thenumberofthepinwhosemodeyouwishtoset
mode: Arduino.OUTPUT , Arduino.INPUT , Arduino.PWM , Arduino.SERVO
Returns
None
DIGITAL
publicvoiddigitalWrite(intpin,bytevalue);
WritetoadigitalpinthathasbeentoggledtooutputmodewithpinMode()method
Parameters
pin: Thedigitalpintowriteto
value: Arduino.HIGH , Arduino.LOW
Returns
None
publicintdigitalRead(intpin);
Returnsthelastknownstateofthedigitalpin
Parameters
pin: TheArduinodigitalinputpin
Returns
Arduino.HIGH or Arduino.LOW
publiceventDigitalPinUpdateddigitalPinUpdated;
CallthisCallbackfunctionwhenthedigitalvalueofthepinwhosemodehasbeensetas Arduino.INPUT update
Delegate
publicdelegatevoidDigitalPinUpdated(bytepin,bytestate);
Parameters
pin: thepinwhosevaluewillupdate
state: Arduino.HIGH , Arduino.LOW
Returns
None
ANALOG
publicvoidanalogWrite(intpin,intvalue);
WritetoananalogpinusingPulse-widthmodulation(PWM)
Parameters
pin: Analogoutputpin
value: PWMfrequencyfrom0(alwaysoff)to255(alwayson)
Returns
None
publicintanalogRead(intpin);
Returnsthelastknownvalueoftheanalogpin
Parameters
pin: TheArduinoanaloginputpin(0~5)
Returns
int: Avaluerepresentingtheanalogvaluebetween0(0V)and1023(5V)
publiceventAnalogPinUpdatedanalogPinUpdated;
Callthisfunctionwhentheanalogvalueofpinwhosemodehasbeensetas Arduino.INPUT update
Delegate
publicdelegatevoidAnalogPinUpdated(intpin,intvalue);
Parameters
pin: thepinwhosevalueupdate
value: Avaluerepresentingtheanalogvaluebetween0(0V)and1023(5V)

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 18/58
Returns
None
SERVO
publicvoidservoWrite(intpin,intangle); WritetheangletospecifiedpinwhichhasbeensetthemodeasServo
Parameters
pin: Servooutputpin.
value: Anglefrom0to180.
Returns
None
I2C/TWOWIRE
publicvoidwireBegin(Int16delay);
InitiatetheWirelibraryandjointheI2Cbusasamaster.Thisshouldnormallybecalledonlyonce
Parameters
delay: thenumberofmillisecondstopause(ms).
Returns
None
publicvoidwireRequest(byteslaveAddress,Int16slaveRegister,Int16[]data,bytemode);
RequestI2Cdevicestosendorreceivedata,thencall didI2CDataReveive eventtohandledatawhenreceivedata.
Parameters
slaveAddress: the7-bitaddressofthedevicetorequestbytesfrom
slaveRegister: Specifytheregisterthatyouwanttostoredataorreaddata,choose Arduino.NONE ifthereisempty.
data :
1.whensettheParameter mode as Arduino.I2C_MODE_WRITE ,thedatasuchas {0x00,0x01} willbesendingtodevices
throughI2CBUS.
2.whensettheParameter mode as Arduino.I2C_MODE_READ_ONCE or Arduino.I2C_MODE_READ_CONTINUOUSLY ,dataspecifythe
lengthofreceiveddata.
mode :
1. Arduino.I2C_MODE_WRITE :Senddata
2. Arduino.I2C_MODE_READ_ONCE :Receivedataonce
3. Arduino.I2C_MODE_READ_CONTINUOUSLY :Receivedatacontinuous
4. Arduino.I2C_MODE_STOP_READING :Stopreceivingdata
Returns
None
publiceventDidI2CDataReveivedidI2CDataReveive;
CallthiseventwhenreceiveI2Cdata.
Delegate
publicdelegatevoidDidI2CDataReveive(byteaddress,byteregister,byte[]data);
Parameters
address: :Specifyslavecomputeraddress
register: :Specifyregisteraddress
data: :Datareturned
Returns
None
EXAMPLES
DIGITALWRITE
Inthisexample,wewillblinktheLEDwhichisconnectedwithdigitalpin(D0-D13)
APIRequired:
1.publicArduino();
2.publicvoidpinMode(intpin,bytemode);

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 19/58
3.publicvoiddigitalWrite(intpin,bytevalue);
HardwareRequired:
1.LattePandax1
2.ledx1(oryoucanusetheLEDattachedtopin13ontheArduinoboarditself)
Circuit:
1.LEDinserteddirectlyintopin13
Code:
1.CreateanewprojectinVisualStudio,RefertoCreateaproject
2.Mainfunctioncode:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.Threading;
usingLattePanda.Firmata;
namespaceblinkYourBoard//projectname
{
classProgram

10/26/2016 Docs|LattePanda
http://www.lattepanda.com/docs/ 20/58
{
staticArduinoarduino=newArduino();//createaninstanceandinitializewiththedefaultparameters
staticvoidMain(string[]args)
{
arduino.pinMode(13,Arduino.OUTPUT);//Setthedigitalpin13asoutput
while(true)
{
//====settheledonoroff
arduino.digitalWrite(13,Arduino.HIGH);//settheLED on
Thread.Sleep(1000);//delayaseconds
arduino.digitalWrite(13,Arduino.LOW);//settheLED off
Thread.Sleep(1000);//delayaseconds
}
}
}
}
Test:
1.ClickDebugbuttontoexecute,theLEDwillstartblinking.
DIGITALREAD
ThisexampledetectstheButtonstatethroughdigitalpin(D0-D13).
APIrequired:
1.publicArduino();
2.publicvoidpinMode(intpin,bytemode);
3.publicintdigitalRead(intpin);
HardwareRequired:
1.LattePandax1
2.Buttonx1
3.Resistor(Resistancevaluegreaterthan1KΩ)x1
Circuit:
Table of contents
Popular Microcontroller manuals by other brands

Embedded Artists
Embedded Artists LPC3250 user guide

Texas Instruments
Texas Instruments Piccolo F280049 user guide

Cypress
Cypress CY8CKIT-001 quick start guide

Vageo
Vageo DT-1 Plus manual

Infineon
Infineon XMC4000 series Application guide

Dialog Semiconductor
Dialog Semiconductor SmartBond DA14585 user manual