Presentation on theme: "EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:"— Presentation transcript:
EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation: Bluetooth communications (Send Message block, Receive Message block) Random behaviors (Random block) Wiring blocks together using Data hubs
EducateNXT Name the two robots Select names for the two robots being used. Robot 1 _______________________ Robot 2 _______________________ These names can be added to the brick as follows:
EducateNXT Name the two robots Enter name here Click the Button straight after the name is typed in. Name will appear on the NXT brick screen.
EducateNXT Plan the actions for the robots ActionBlock(s) required 1. (e.g. “Turn left for 1 second”) (e.g. “Move block”) 2. (e.g. “Go forward 2 rotations”) (e.g. “Move block”) Copy and fill out the table:
EducateNXT Program and randomize the actions Two programs are required: Leader and Follower Leader program Program randomly selects one of the two actions (e.g., forward for 1 rotation) Follower program Copies the action of the Leader Receives Bluetooth message Sends action via Bluetooth Animation in progress
EducateNXT Program and randomize the actions Start a new program Leader’s program first or Program starts with a Loop as the leader will need to keep creating steps indefinitely.
EducateNXT Program and randomize the actions The leader will perform one of their two actions randomly. A Random block will be required from the Complete palette. The Random block is dragged into the loop. Minimum is set to 0. Maximum is set to 1.
EducateNXT Program and randomize the actions A Switch is added (from either the Common or Complete palettes). Control = Value Type = Number In the Switch configuration panel:
EducateNXT Program and randomize the actions Wire from the Random Block to the switch As in the above animation – use left mouse click to change direction. … And one more time. Animation in progress
EducateNXT Program and randomize the actions Place the actions you wrote down into the switch.
EducateNXT Sending a message via Bluetooth Select and drag the Send Message icon into the Leader program. Leave both the Connection and Mailbox in the Configuration panel set at 1.
EducateNXT Sending a message via Bluetooth Open the Send Message block’s data hub by clicking on the bottom- left of the block (as shown).
EducateNXT Sending a message via Bluetooth Draw out another wire from the Random block. Wire to the Number Plug on the Send Message block.
EducateNXT That is the finished Leader’s Program. This can be downloaded to the Leader’s brick. Don’t run it yet. The Follower needs to be programmed.
EducateNXT Programming the Follower 0 1 What action? Wait for a Bluetooth message Do action 1 Do action 0 A flowchart of the Follower’s program
EducateNXT Programming the Follower Drag a Receive Message Block into a Loop. The loop means it will continually allow the Follower to look for a Bluetooth message before acting on it. Set the loop to Control = Logic and Until = True
EducateNXT Programming the Follower Set the Message to Number. Wire from the “Message Received” data hub point to the “Loop Condition” as shown. Once a message is received the program will now break out of the loop.
EducateNXT Programming the Follower Add a switch block set to Value. Wire from Number Out to the Switch. And add the action blocks you used in the Leader’s program. Download this program to the Follower’s brick. Animation in progress
EducateNXT Connecting the bricks Before the two programs can be run, a Bluetooth connection needs to be established between the two bricks. To do this you will need to access the “Educate NXT” PowerPoint called Establishing a Bluetooth Connection Leader = MasterFollower = Slave
EducateNXT Happy Following! Once the Bluetooth connection has been established, run both programs at the same time.
Your consent to our cookies if you continue to use this website.