Thread: PBasic Question
View Single Post
  #14   Spotlight this post!  
Unread 31-10-2002, 16:46
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Ok, I'm back (sort of). Actually, I'm sitting in my CSci class right now, but I don't really feel like listening, so I'm responding here.

The p1_sw_top_prev=p1_sw_top does exactly what Matt said, it stores the state for the next loop. Since almost no one can press and release a button within 1/40th of a second, we need to make sure that it is actually a "new" button press and not just someones finger left on the switch from earlier. This lets us use the top switch as a toggle. I.e. each time you press it, the gear we are in changes.

As for the timing, it ends up being about 1.5-2 seconds from the time you press the button to the time you can drive again. That is for the full 40 loops. The 10 loop part takes approx. 1/4 as long.

If you can understand this type of time-delay, you have a very good grasp on PBASIC as this type of looping isn't overly intuitive.

Anyway, let me know if there are any other sections that are unclear or don't make sense.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php