View Single Post
  #5   Spotlight this post!  
Unread 10-02-2002, 01:11
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Another error

Quote:
Originally posted by Joelster

This is our other flaw.....think you can make it work??? please reply asap!!
Well I see A problem. Remember your switches, joysticks, etc are read with the serin command at the top of the main loop.

Once you get to your loop: label, you're just going to sit there spinning forever since you never execute the serin command again.

Since I'm not sure what you're trying to accomplish with this code, I hesitate to try rewriting it... but I'll give it a try

It looks like maybe what you're wanting to do is turn on a motor when the switch transitions from open to closed, and then turn off the motor the next time the switch transitions from open to closed. Here is what I would do for that:

Code:
'if switch just pressed, turn motor on/off
if prev_sw = 1 or p1_sw_top = 0 then dont_change_relay
  relay7_fwd = relay7_fwd ^ 1      ' XOR toggles the bit
dont_change_relay:

prev_sw = p1_sw_top                  ' Save switch state for next time
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me