Today in class we were introduced to a new challenge made by our own member Anh Nguyen
the task was to use the sonar senors and finish the task basically the task was to keep the robot hitting the box and the wall. as a class we came up with right code.
Below is the code :
"
void ss ()
{
while(SensorValue(sonarsensor) > 45 )
{ motor[motorC]=100;
motor[motorB]=100;
{
motor[motorB]=0;
motor[motorC]=0;
wait1Msec(2000);
}
void rightturn()
{
nMotorEncoder[motorB]=0;
nMotorEncoder[motorA]=0;
nMotorEncoderTarget[motorC]=379;
while(nMotorEncoder[motorC] < 379;
{
motor[motorC]=100;
motor[motorB]=100;
}
motor[motorC]=0;
motor[motorB]=0;
wait1Msec(1000);
task main ()
{
ss();
rightturn();
nMotorEncoder[motorB]=0;
nMotorEncoder[motorC]=0;
ss();
nMotorEncoderTarget[motorB]=0;
nMotorEncodertarget[motorC]=0;
while (nMotorEncoder[motorB]> 0)
{
motor[motorB]= -100;
motor[motorB]= -100;
}
motor[motorC]=0;
motor[motorB]=0;
wait1Msec(2000)
target
}
"
Tuesday, July 14, 2009
Subscribe to:
Post Comments (Atom)

That was not the task. Please revisit this post and be more keen to your comments.
ReplyDelete