View Single Post
  #2   Spotlight this post!  
Unread 09-02-2005, 11:08
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Need some order in programming!

Quote:
Originally Posted by Jatheon4316
I've run into a bit of a pickle with my coding... When writing programs for stuff like joysticks etc, it's fine if the program runs every time the microprocessor refreshes(actually that's a good thing!). However, what if you don't want that to happen? An example in autonomous mode: you want to take a reference bearing with a digital compass at the beginning of the game. How do you prevent the robot from getting a new "first bearing" every time the processor loops? Or how about ordered events? If I want the robot to drive forward for a certain amount of time and then extend the arm, how do I prevent it from driving forward if it's already done so (when the processor refreshes)?

Is there some way to carefully control when pieces of code are carried out? Perhaps static integers or "do while" loops (Initialize integer an integer at 0. If you carry out the enclosed piece of code, mark the integer as a 1-so it won't repeat...)?

Help!
Do a search on "state machine" and "state variable" for your answer.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org