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