View Single Post
  #2   Spotlight this post!  
Unread 01-02-2012, 12:44
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Autonomous with Ultrasonic sensor doesnt work!!

Quote:
Originally Posted by cilginbilgin View Post
Here is the code I have written for autonomous. I want the robot to stop and the piston to extend when the ultrasonic sensor reads 40 inches. But it doesnt happen. We have tested the ultrasonic sensor and tuned it. We are sure that the distance ultrasonic sensor reads is true.

Can anyone tell me if the code is correct or wrong?
Thanks in advance.

http://imageshack.us/photo/my-images...tonomous2.png/

http://imageshack.us/photo/my-images...utonomous.png/
The portion of the code in the "while loop" will run continuously. The portion outside of the "while loop" will only run once (as soon as autonomous starts), and will never run again. Therefore, the code that is checking the ultrasonic sensor is never checked after the start of autonomous.

Remove the "while loop" around the motors, and place the while loop around all of your code. That should fix the problem.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote