Need Help With A Bit Of Coding

I have a question about the code, so i use vex iq and im trying to make a auto collision detection for the distance sensor i have if f down pressed move forward until distance sensor is within 5 inches than it says move backwards and than it says turn 90 degrees it just doesn’t stop turning i tried like everything and it doesn’t work can somebody please help, than would be lovely and much appreciated

The best way to get help with code is to post it so people can see where its going wrong.

1 Like

ok good idea ill do it tomorrow bc its gettin late

15%20PM

It moves forwad until within 5 inches moves back 5 inches and it says turn 90 degrees but it never stops turning

You set the heading to 0, and then want it to go to 180 near then end, so this should make it turn around.

image

One thing I don’t like about using a drivetrain is that you can’t access the motors or gyro outside of the drivetrain class. So if you want to use a gyro in the drivetrain you can’t get the heading or calibrate the gyro. If you have a calibration issue there’s not much you could do about it.

I don’t see the 90 degrees. And do you mean that it is turning and just keeps spinning and spinning and spinning???

1 Like

I remember there was a way to do it without a gyro i did it first try but deleted the code by accident

I am sure you’ve checked, but is Front / Back correctly designated in drive train settings? A student encountered a similar scenario to what you are describing. He had inadvertently placed his machine so that it ‘appeared’ to be moving forwards and backwards. When turning the machine would endlessly spin as the value from the gyro was different to expected. Try reversing Drive Chain direction.
image