Answers.Body: <p>Debugging tip: Inside of the wait loop, print the gyro angle on the screen so that you can see what the actual value is.</p>
  
  <hr>
  
  <p>In your code, I see...</p>
  
  <pre><code>setMotor(motorB, 35);
  setMotor(motorC, -35);
  </code></pre>
  
  <p>...which presumably causes the robot to rotate clockwise. And also...</p>
  
  <pre><code>setMotor(motorB, -35);
  setMotor(motorC, 35);
  </code></pre>
  
  <p>...which presumably rotates the robot counter clockwise. <em>But</em>, you always have...</p>
  
  <pre><code>waitUntil (getGyroDegrees(gyroSensor) &gt; 80);
  </code></pre>
  
  <p>I would assume that when you rotate counter-clockwise that the angle gets smaller (or it could be the opposite depending on which way the gyro is oriented). In this case, I would thing you need...</p>
  
  <pre><code>waitUntil (getGyroDegrees(gyroSensor) &lt; -80);
  </code></pre>
  
  <p>...instead since the value will be decreasing from 0.</p>
  
  <hr>
  
  <p>You also need to be aware of <a href="https://bricks.stackexchange.com/q/7115/3498">gyro drift</a> that can cause the angle to change even when the robot is not moving. Calling <code>resetGyro(S2);</code> resets the angle reading to 0, but it probably does not "calibrate" the sensor to eliminate drift. Common ways of doing this are unplugging the sensor and plugging it back it and changing the "mode" of the sensor (e.g. by reading rate and then reading angle).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-05T22:55:27.627Z
Answers.LastActivityDate: 2016-01-05T22:55:27.627Z
Answers.LastEditDate: 2017-04-13T12:47:56.390Z
Answers.UserDisplayName: David Lechner
Body: <p>Currently the gyro sensor connected to the EV3 brick doesn't really work. whenever the gyro is attempted to be used the robot will just sit and spin once it gets to where it needs to use the gyro. Any suggestions would be appreciated</p>
  
  <pre><code>forward(4.8, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, 35);
  setMotor(motorC, -35);
  waitUntil (getGyroDegrees(gyroSensor) &gt; 80);
  forward(2, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, 35);
  setMotor(motorC, -35);
  waitUntil (getGyroDegrees(gyroSensor) &gt; 80);
  forward(4.8, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, -35);
  setMotor(motorC, 35);
  waitUntil (getGyroDegrees(gyroSensor) &gt; 80);
  forward(2, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, -35);
  setMotor(motorC, 35);
  waitUntil (getGyroDegrees(gyroSensor) &gt; 80);
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-23T20:07:21.413Z
Comments.Text: It is not clear exactly what you are asking. Can you post your code? Also see http://bricks.stackexchange.com/questions/7115/how-can-ev3-gyro-sensor-drift-be-handled
Comments.UserDisplayName: David Lechner
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-04T19:31:14.510Z
Comments.Text: I have put the code up
Comments.UserDisplayName: Jacob Eshelman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-05T03:09:42.043Z
Comments.Text: What programming language is this?
Comments.UserDisplayName: David Lechner
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-05T19:22:07.293Z
Comments.Text: the language is what is created in the Graphical ROBOTC for LEGO Mindstorms 4.x
Comments.UserDisplayName: Jacob Eshelman
Tags: <ev3><robotc><gyro>
Title: How to fix the Gyro
UserDisplayName: Jacob Eshelman
ThreadText: # How to fix the Gyro
  
  (Asked by: username_0 on 2015-12-23)
  
  Currently the gyro sensor connected to the EV3 brick doesn't really work. whenever the gyro is attempted to be used the robot will just sit and spin once it gets to where it needs to use the gyro. Any suggestions would be appreciated
  forward(4.8, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, 35);
  setMotor(motorC, -35);
  waitUntil (getGyroDegrees(gyroSensor) > 80);
  forward(2, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, 35);
  setMotor(motorC, -35);
  waitUntil (getGyroDegrees(gyroSensor) > 80);
  forward(4.8, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, -35);
  setMotor(motorC, 35);
  waitUntil (getGyroDegrees(gyroSensor) > 80);
  forward(2, rotations, 50);
  wait(.5, seconds);
  resetGyro(S2);
  setMotor(motorB, -35);
  setMotor(motorC, 35);
  waitUntil (getGyroDegrees(gyroSensor) > 80);
  
  **Tags:** ev3, robotc, gyro
  > **Comments:**
  > **username_1**: It is not clear exactly what you are asking. Can you post your code? Also see http://bricks.stackexchange.com/questions/7115/how-can-ev3-gyro-sensor-drift-be-handled  
  > **username_0**: I have put the code up  
  > **username_1**: What programming language is this?  
  > **username_0**: the language is what is created in the Graphical ROBOTC for LEGO Mindstorms 4.x  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-05. Score: 2
  
  Debugging tip: Inside of the wait loop, print the gyro angle on the screen so that you can see what the actual value is.
  
  In your code, I see...
  setMotor(motorB, 35);
  setMotor(motorC, -35);
  
  ...which presumably causes the robot to rotate clockwise. And also...
  setMotor(motorB, -35);
  setMotor(motorC, 35);
  
  ...which presumably rotates the robot counter clockwise. But, you always have...
  waitUntil (getGyroDegrees(gyroSensor) > 80);
  
  I would assume that when you rotate counter-clockwise that the angle gets smaller (or it could be the opposite depending on which way the gyro is oriented). In this case, I would thing you need...
  waitUntil (getGyroDegrees(gyroSensor) < -80);
  
  ...instead since the value will be decreasing from 0.
  
  You also need to be aware of gyro drift that can cause the angle to change even when the robot is not moving. Calling resetGyro(S2); resets the angle reading to 0, but it probably does not "calibrate" the sensor to eliminate drift. Common ways of doing this are unplugging the sensor and plugging it back it and changing the "mode" of the sensor (e.g. by reading rate and then reading angle).
  
  
  ---
  
  