Download presentation
Presentation is loading. Please wait.
Published byMay Johnston Modified over 9 years ago
1
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
2
Variable Store value under a name and then re-use NXT-G –Need to set up variable: name and data type Logic (true or false) Number Text –Then can read or write –Use as input to data link –Use as input to calculation Demonstrate
4
Button test Use variable to hold which NXT button was pressed. Use Edit/Define Variables –Need to give name (give meaningful name) –Need to specify datatype (number, text, logic)
5
Warnings If the task is to determine left or right button, you can’t wait for one button. Instead, loop checking first one then the other button. Set variable (or use data wires and an OR operation) to exit the loop. Probably need to insert pause(s).
7
How to check? Use display screen –Text –Specify text –NEED TO INSERT PAUSE SO I CAN SEE IT!
9
Lab assignment Do basic ball hitting exercise –Hit only red ball and only blue ball. Enhance hitting ball exercise –Use buttons to indicate which ball is to be hit –Use variable –NOTE: you probably can do this just with data wires, but do it with a variable Why?
10
File Set of values Can be re-used by program or uploaded to computer NXT-G –Delete (might do this initially to make sure there isn’t old file by the same name) –Write (actually append to end) –Close (need to do this before reading) –Read Demonstrate
11
First part: records light readings
12
Second part: write out file
13
…and you can upload file: Other under Memory
14
Rotation sensor Connect to particular motor. Reset to zero. Can measure in rotations or degrees.
16
Mapping Now have tools to record how far robot has moved –Rotation sensor: how many degrees a particular motor has turned –Variables and files to store data Need a plan/strategy to 'map room' –Determine position of walls –Note: you know how to move until bump or move until ultrasonic indicates under a set amount.
17
Challenges Robot to store (for later use) where it found walls (or something else) –Use rotation sensor to determine distance traveled (will need to calibrate in terms of power) –Create file –Upload file LATER: Robot to send information to second robot using Bluetooth.
18
Lab/Homework Use ultrasound than light to hit the red ball. Change to hit the blue ball Use display, pause, buttons to specify which ball to hit. Start planning room mapping task. Postings
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.