Advanced Ev3 Programming Lesson

Transcription

ADVANCED EV3PROGRAMMING LESSONIntroduction to BluetoothBy Sanjay and Arvind Seshan

Objectivesì Learn how to use the Bluetooth functionality on your EV3ì Learn to send and receive messages between EV3 bricksCopyright EV3Lessons, 2016, Last Edit 7/19/2016

What is Bluetooth?ì Bluetooth uses radio frequencies to communicate betweendevicesì The EV3 uses Bluetooth to download programs wirelesslyì The EV3 also uses Bluetooth to connect to another EV3Copyright EV3Lessons, 2016, Last Edit 7/19/2016

Why Use Bluetooth on the EV3?ììControlling a large single robotwith multiple bricksAn alternative to daisy chaining:Requires less wiring but needsseparate programsCopyright EV3Lessons, 2016, Last Edit 7/19/2016ì Coordinating multiple robotsììHave them perform similaractionsSynchronize their actions

Tips for Successì Give each brick an unique name (Sender and Receiver for thislesson)ì Use an USB cable for downloading code to the bricks (ratherthan Bluetooth). You cannot connect between EV3s and a PC atthe same timeì Turn on the receiver robot first then the sender in thechallenges in this lesson. This is because the challenge solutiononly sends the message once in Challenge 1.Copyright EV3Lessons, 2016, Last Edit 7/19/2016

Activating Bluetooth on the EV3ì Turning on Bluetooth:ì On the EV3 menu, go to thesymbol that looks like a wrenchì Go down to the word “Bluetooth”and activate itì To connect to another brick go backinto the Bluetooth menuììGo to “Connections”Select “Search” and find the otherbrick’s nameì You can also manage yourconnections with the BluetoothConnection Block. But we do notuse this block in this lesson.Copyright EV3Lessons, 2016, Last Edit 7/19/2016

New Block: Messagingì The messaging blockcan be found in theBlue Pallet.ì You will also use theWait For block inMessaging ModeCopyright EV3Lessons, 2016, Last Edit 7/19/2016

Challenge 1ìSend a “Hello World” messagefrom one brick to anotherìThe second brick should receiveand display the message on itsscreen for 5 secondsìTips:ììììYou will need to pair the tworobots ahead of timeName one robot Sender and theother Receiver for this challengeFor this challenge, you will usethe Messaging block à Send àTextYou will use the Wait For block inthe Messaging Mode à Changeà TextCopyright EV3Lessons, 2016, Last Edit 7/19/2016Video

Challenge 1 SolutionCode onthe SenderRobotSends the message “Hello World”to the Receiver robot. The messagetitle “Greeting” must match in thereceiver’s program.Code on the Receiver RobotCopyright EV3Lessons, 2016, Last Edit 7/19/2016Wait for a message fromthe first robot and displaythe text for 5 seconds

Challenge 2: Synchronized Swimmersì Move the first robot by handand send the motors’ powerto the other robotì Have the second brick receivethe data and copy themovementCopyright EV3Lessons, 2016, Last Edit 7/19/2016

Challenge 2 SolutionCode on the Sender RobotCode on the Receiver RobotRead the two differentmessage titles and applythe received power valuesCopyright EV3Lessons, 2016, Last Edit 7/19/2016Read each of the motors’ powerand send them using two differentmessage titles to the Receiver robot

Putting it all TogetherìOnce you know how to use Bluetooth on theEV3, you can create complex robots wheremovement is coordinated and synchronizedìMaster Lee Magpili’s Eagle is an example ofsuch a project where Bluetooth messages areused to coordinate head, leg and wingmovement. (Photos and code posted withpermission.) Another brick uses Bluetooth toremotely control the Eagle.ìThis project requires the following parts for thebird and a remote:ì5 EV3sì17 Motorsì2 Touch SensorsCopyright EV3Lessons, 2016, Last Edit 7/19/2016

The EagleThis is small part of the Eagle’s code. Here you see that the Eagle has five modes. Inthis view, you see that messages are being sent to “Legs1” and “Wings” EV3 bricks.Thank you to Master Lee Magpili for sharing his code with EV3Lessons.Copyright EV3Lessons, 2016, Last Edit 7/19/2016

Activating Bluetooth on the EV3 ì Turning on Bluetooth: ì On the EV3 menu, go to the symbol that looks like a wrench ì Go down to the word "Bluetooth" and activate it ì To connect to another brick go back into the Bluetooth menu ì Go to "Connections" ì Select "Search" and find the other brick's name ì You can also manage your