Download presentation
Presentation is loading. Please wait.
Published byTiffany Conley Modified over 9 years ago
1
NXT Development Tutorial Part 3: Robot Arm NTHU CS Freshman Camp Shu-Ting Wang
2
Links http://nmsl.cs.nthu.edu.tw/dropbox/RobotArm_CScamp.zip http://nmsl.cs.nthu.edu.tw/dropbox/CSCamp_Day4.pptx
3
While() while(condition){ ….something… } Keep doing something until the condition is not true For example, keep walking until you see Delta building while (I don’t see Delta){ walk }
4
If() if(condition){ ….something A… } else ….something B… } Do something if the condition is true For example if (I am hungry){ I go to find something to eat } else{ play LOL }
5
Lab 1 Add a touch sensor at port S2. while(touchSensor2.isPressed()) { …Stop all motors… …Jump out of the outer while loop…. }
6
Manual Controlled Robot Arm while(Button.ESCAPE.isDown()) { Motor.B.setSpeed(speed); Motor.B.backward(); if(Button.ESCAPE.isUp()) { Motor.B.stop(); break; }
7
Lab 2 Write two while loops so that we can use Button.LEFT and Button.RIGHT to control motor A It’s very similar to the last page example
8
Bonus: Lab 3 Write a code snippet to catch a ball automatically Hint1: Keep the motor moving until it rotates to certain angel Motor.B.rotateTo(limited_Angle); Hint2: detect the ball using ultrasonic sensor. We did similar things in the tracker.java example
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.