Program

From Control Systems Technology Group
Jump to navigation Jump to search

On this page the programming of the RCX 2.0 bricks will be updated and saved.


V1, simple driving and turning loop

task main() {

 int i = 0;
 do
 {
   motor[motorA] =  100;    //motor A is run at a 100 power level
   motor[motorC] =  100;    //motor C is run at a 100 power level
   wait1Msec(2000);         //the program waits 3000 milliseconds before running further code
   //ClearSensorValue(rotationSensorA);                                                //rotation sensor A is reset to 0
   //ClearSensorValue(rotationSensorB);                                                //rotation sensor B is reset to 0
   //while(SensorValue(rotationSensorA) < 320 && SensorValue(rotationSensorB) > -320)  //a while loop is delcared with rotation sensor A less than 320 AND rotation sensor B greater than -320 as its true condition
   //{
   //motor[motorA] = 100;	                                                    //motor A is run at a 100 power level
   //motor[motorB] = -100;                                                           //motor B is run at a -100 power level
   //}
   motor[motorA] =   100;   //motor A is run at a 100 power level
   motor[motorC] =  -100;   //motor C is run at a 100 power level
   wait1Msec(500);          //the program waits 3000 milliseconds before running further code
   i++;                     //the variable "i" is incremented by one
 }
 while(i < 10);             //after each iteration of the loop is conducted, the truth condition, "i" less than 20, is checked

}

Back to: PRE2015_2_Groep1