So I’m thinking of having my kids practice coding and the ROBOTC for VEX cortex has a really awesome guide and lets you practice with some basic coding. I was really getting the hang of it but really cannot figure out what it is asking me to do for the Labyrinth Challenge.
Here is the instructions that were provided:
- Move forward full speed for 2.3 seconds
- Stop both motors for 1 second
- Swing turn to the right at full power for 1.5 seconds
- Stop both motors for 1 second
This is the code it had also provided:
task main()
{
//move forward full power for 3.5 seconds
motor[port2] = 127;
motor[port3] = 127;
wait1Msec(3500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//turn left
motor[port2] = 127;
motor[port3] = 0;
wait1Msec(1500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//END OF FIRST LENGTH
And finally here is what I changed it to but it says this is not correct:
task main()
{
//move forward full power for 2.3 seconds
motor[port2] = 127;
motor[port3] = 127;
wait1Msec(2300);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//turn left
motor[port2] = 0;
motor[port3] = 127;
wait1Msec(1500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//END OF FIRST LENGTH
}
When I ask for a hint it says: most of the code is already written so change the values.
I would appreciate any help! Thank you!
for turning right you also probably want to set motor[port2] in full reverse, or -127
Just for reference, you can use ```
to format your code.
This is the code provided:
task main()
{
//move forward full power for 3.5 seconds
motor[port2] = 127;
motor[port3] = 127;
wait1Msec(3500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//turn left
motor[port2] = 127;
motor[port3] = 0;
wait1Msec(1500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//END OF FIRST LENGTH
}
This is your altered code:
task main()
{
//move forward full power for 2.3 seconds
motor[port2] = 127;
motor[port3] = 127;
wait1Msec(2300);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//turn left
motor[port2] = 0;
motor[port3] = 127;
wait1Msec(1500);
//stop
motor[port2] = 0;
motor[port3] = 0;
wait1Msec(1000);
//END OF FIRST LENGTH
}
Your code seems correct, perhaps you should change all the comments to reflect your code. I notice that the comment still says turn left instead of turn right.
Also @DrewWHOOP,
Swing turn would not require the other motor to reverse (since that would make it a point turn) .
6 Likes
Thank you, I did try to change the comments in green as well but this did not work either. I am pretty stumped because I do believe I have the code right. I will continue to try to problem solve!
1 Like
Vex really out here with secret STEM problem-solving challenges
1 Like
I know I was enjoying the practice a lot but found it pretty difficult and did not want to try it with the kids I teach if I can’t even figure it out myself first haha!