180 likes | 192 Vues
Robotics. NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room. 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
E N D
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
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
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)
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).
How to check? • Use display screen • Text • Specify text • NEED TO INSERT PAUSE SO I CAN SEE IT!
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?
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
Rotation sensor • Connect to particular motor. • Reset to zero. • Can measure in rotations or degrees.
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.
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.
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