What is the syntax for a boolean OR in a While loop?
Say you have a variable called gyroSens that the gyro reading is stored in and you want to execute some code while it is outside some thresholds to straighten the robot, i.e.
while(gyroSens > 5 || gyroSens < -5)
if(gyroSens > 5)
if(gyroSens < -5)
One of our schools is struggling with this and I couldn’t find the answer in the help file!
“||” is a logical (boolean) OR. “&&” is logical AND.
Don’t forget to update the “gyroSens” variable each time around the loop. I would also add some delay (ie. a Wait(25) ) statement so that the loop doesn’t run as fast, this gives the motors some time to react to the new drive commands.
So the syntax of the while loop is correct? This is how I’d write it in ROBOTC so I assumed so. They are updating the gyro value in the loop but I guess the issues are related to the other gyro issues on my thread in the technical forum.
Thanks for the helpful replies!