In part one drive straight with proportional control of the mini series on how to make reliable programming skills in VEX IQ Challenge. If you haven’t read that post yet, I recommend doing that and then coming back to this post. We will do a square test at the end of this post, which uses the drive straight my block from part one.
839 coding tutorial
Precise turn code snippet for VEXcode Blocks.
Create a my block for turn. Robot will carry a momentum and continue turning even after the stop command has been sent, so we will stop the motor before robot reaches its target angle.
Please note VEX IQ gyro sensor has a positive value when turning left, and negative when turning right. For more information about VEX IQ gyro sensor, please check VEX KB Using the VEX IQ Gyro Sensor.
Calling turn my block
At the beginning of the program, make sure you set the motor brake mode to brake and calibrate the gyro for 2 seconds. Then you can simply call turn we created earlier.
Heading: 90 – target heading that robot should turn to
Velocity: 10 – how fast the robot should turn, please note this is an spot turn (left wheel and right wheel travelling at opposite speed at the same time, hense it’s 2x speed)
Momentum: 5 – how many degrees you are expecting the robot will carry after it’s stopped. e.g. turning into 90 degrees with 5 as momentum will stop the robot from moving at 85 degrees.
Did I mention that we do have FREE coding classes run by our high school students volunteers, that’s a great opportunity to get your kids started taking instructed coding classes with absolutely no cost.
If you have any questions or comments, please leave them below!