lecture3_motors_and_sensors - 9/27/2010 Motors and Sensors...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
9/27/2010 1 Ò Motors and Sensors Program Revisited Let’s look at our sample program again task main() contains the behaviors that we want the robot to do, and the { and } “braces” surround the body of the structure. The lines between the braces tell the program what commands to follow as part of the main task Program Revisited The code currently tells the robot to move in a circle Ò It tells the robot to move “Motor C” forward for 3 seconds. Ò Moving only one motor or wheel will make your Moving only one motor, or wheel, will make your robot go in circles Ò The motor[] command tells the robot to set a motor to run at a given power level Ò The command “wait1Msec” tells the robot to wait for the given time in milliseconds. 3000 milliseconds is equal to 3 seconds, so the robot moves for 3 seconds
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
9/27/2010 2 Moving Forward In order to make the robot go forward, you’ll want both motor C and motor B to run forward Ò The command motor[motorC]=100; made Motor C move at 100% power Ò Add a command that is exactly the same, but addresses Motor B instead task main() { motor[motorC] = 100; motor[motorB] = 100; wait1Msec(3000); } Timing and Distance Ò Adjusting the length of time a robot moves forward will affect the distance the robot travels. Adjust the amount of time the robot lets its motors run, by changing the number value inside the wait1Msec command Ò We can test these adjustments by editing the program in RobotC and downloading them to the Robot Speed and Direction Ò Change the power levels in your motor[] commands to move at half speed. The numeric value assigned to each motor in the motor[] commands represents the % of power of the motors Ò Can enter negative values to make motors go in reverse
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

lecture3_motors_and_sensors - 9/27/2010 Motors and Sensors...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online