ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì...

13
ADVANCED EV3 PROGRAMMING LESSON Introduction to Bluetooth By Sanjay and Arvind Seshan

Transcript of ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì...

Page 1: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ADVANCEDEV3PROGRAMMINGLESSON

IntroductiontoBluetoothBySanjayandArvindSeshan

Page 2: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì LearnhowtousetheBluetoothfunctionalityonyourEV3

ì Learntosendandreceivemessages betweenEV3bricks

Objectives

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 3: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì Bluetoothusesradiofrequenciestocommunicatebetweendevices

ì TheEV3usesBluetoothtodownloadprogramswirelessly

ì TheEV3alsousesBluetoothtoconnecttoanotherEV3

WhatisBluetooth?

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 4: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì Coordinatingmultiplerobotsì Havethemperformsimilar

actionsì Synchronizetheiractions

CopyrightEV3Lessons,2016,LastEdit7/19/2016

WhyUseBluetoothontheEV3?

ì Controllingalargesinglerobotwithmultiplebricks

ì Analternativetodaisychaining:Requireslesswiringbutneedsseparateprograms

Page 5: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì Giveeachbrickanuniquename(SenderandReceiverforthislesson)

ì UseanUSBcablefordownloadingcodetothebricks(ratherthanBluetooth).YoucannotconnectbetweenEV3sandaPCatthesametime

ì Turnonthereceiverrobotfirstthenthesenderinthechallengesinthislesson.ThisisbecausethechallengesolutiononlysendsthemessageonceinChallenge1.

TipsforSuccess

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 6: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ActivatingBluetoothontheEV3

ì TurningonBluetooth:ì OntheEV3menu,gotothe

symbolthatlookslikeawrenchì Godowntotheword“Bluetooth”

andactivateit

ì ToconnecttoanotherbrickgobackintotheBluetoothmenuì Goto“Connections”ì Select“Search”andfindtheother

brick’sname

ì YoucanalsomanageyourconnectionswiththeBluetoothConnectionBlock.Butwedonotusethisblockinthislesson.

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 7: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì ThemessagingblockcanbefoundintheBluePallet.

ì YouwillalsousetheWaitForblockinMessagingMode

NewBlock:Messaging

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 8: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì Senda“HelloWorld”messagefromonebricktoanother

ì Thesecondbrickshouldreceiveanddisplaythemessageonitsscreenfor5seconds

ì Tips:ì Youwillneedtopairthetwo

robotsaheadoftimeì NameonerobotSenderandthe

otherReceiverforthischallengeì Forthischallenge,youwilluse

theMessagingblockà SendàText

ì YouwillusetheWaitForblockintheMessagingModeà Changeà Text

Challenge1

Video

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 9: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

Challenge1Solution

CodeontheSenderRobot

CodeontheReceiverRobot

Sendsthemessage“HelloWorld”totheReceiverrobot.Themessagetitle“Greeting”mustmatchinthereceiver’sprogram.

Waitforamessagefromthefirstrobotanddisplaythetextfor5seconds

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 10: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì Movethefirstrobotbyhandandsendthemotors’powertotheotherrobot

ì Havethesecondbrickreceivethedataandcopythemovement

Challenge2:SynchronizedSwimmers

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 11: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

Challenge2Solution

CodeontheSenderRobot

CodeontheReceiverRobot

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Readeachofthemotors’powerandsendthemusing twodifferentmessagetitlestotheReceiverrobot

Readthetwodifferentmessagetitlesandapplythereceivedpowervalues

Page 12: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

ì OnceyouknowhowtouseBluetoothontheEV3,youcancreatecomplexrobotswheremovement iscoordinatedandsynchronized

ì MasterLeeMagpili’s EagleisanexampleofsuchaprojectwhereBluetoothmessagesareusedtocoordinatehead,legandwingmovement.(Photosandcodepostedwithpermission.) AnotherbrickusesBluetooth toremotelycontroltheEagle.

ì Thisprojectrequires thefollowing partsforthebirdandaremote:ì 5EV3sì 17Motorsì 2TouchSensors

PuttingitallTogether

CopyrightEV3Lessons,2016,LastEdit7/19/2016

Page 13: ADVANCED EV3 PROGRAMMING LESSONev3lessons.com/en/ProgrammingLessons/advanced/Bluetooth.pdf · ì Once you know how to use Bluetooth on the EV3, you can create complex robots where

CopyrightEV3Lessons,2016,LastEdit7/19/2016

TheEagle

ThisissmallpartoftheEagle’scode.HereyouseethattheEaglehasfivemodes.Inthisview,youseethatmessagesarebeingsentto“Legs1”and“Wings”EV3bricks.

ThankyoutoMasterLeeMagpili forsharinghiscodewithEV3Lessons.