View Single Post
  #3   Spotlight this post!  
Unread 08-03-2003, 19:59
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
Jeff_Rice's code should work for you. If you want some more info on why the original code wouldn't work, read on. Otherwise, just ignore the rest of this.

Here goes:
1. None of the variable names actually mean anything. For example, you could rename relay1_fwd to relay7_rev and as long as you updated the aliases correctly, the Stamp wouldn't know the difference.
2. Just setting a variable won't change the motor itself. In fact, setting the variables are just a matter of convience and allow for more complex processing.
3. The motors are actually set by the values passed to the SEROUT command.

Since the original code never reaches a SEROUT between the relay1_fwd = 1 and the relay1_fwd = 0, the relay will never know the difference. Furthermore, if you don't do a SEROUT at least once every 5 loops (that's ~125ms), you'll get a Basic Run Error. RoboEmu is a little more forgiving and will only complain after 1s which is probably why you didn't get any actual errors.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php