Autobot’s rollout – 12 May 2017

  • Introduce students to Robot C who weren’t present last session.
  • Break down of the code structure/syntax.
  • The importance of correct punctuation and upper/lower case when coding.
  • Remarking // commenting /**/ on each line of code while learning.
  • Show how to configure Pragmas for each individual motor including speed and reversing.
  • Demonstrate writing a basic code to enable the robot to drive forward, point turn and return with wait times included. Explain the reason why we power down the motors.
#pragma config(Motor, port1, rightMotor, tmotorVex393_HBridge, openLoop, driveRight)

#pragma config(Motor, port10, leftMotor, tmotorVex393_HBridge, openLoop, reversed, driveLeft)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
/*

Steve's experimental robot

Robot will wait, move forward, wait, 180 deg point turn, wait, move forward back to where it started.

*/

wait1Msec (6000); // This command will cause the program to 'wait' for 6 sec before executing so we have time to put the robot down

motor [rightMotor] = 127; // This command will turn on the right motor at full power of 127
motor [leftMotor] = 127; // This command will turn on the left motor at full power of 127
wait1Msec (6000); // This command will cause the motors to run for 6 sec

motor [rightMotor] = 0; // This command will turn off the right motor
motor [leftMotor] = 0; // This command will turn off the left motor
wait1Msec (1000); // This command will keep the motors turned off for 1 sec

motor [rightMotor] = 63; // This command will turn on the right motor at half power of 63
motor [leftMotor] = -63; // This command will turn on the left motor at half power of 63 but reversed so that it will perform a point turn
wait1Msec (2000); // This command will cause the motors to run for 2 sec

motor [rightMotor] = 0; // This command will turn off the right motor
motor [leftMotor] = 0; // This command will turn off the left motor
wait1Msec (1000); // This command will keep the motors turned off for 1 sec

motor [rightMotor] = 127; // This command will turn on the right motor at full power of 127
motor [leftMotor] = 127; // This command will turn on the left motor at full power of 127
wait1Msec (6000); // This command will cause the motors to run for 6 sec

}

 

 

  • Students to start setting up pragmas for the claw and arm motors, noting that these needed speed controllers as only two ports have these built into the Cortex.
  • Write code that includes operating these extra two motors.
  • Capture and write up their blogs.

Leave a Reply