View Single Post
  #2   Spotlight this post!  
Unread 08-02-2002, 21:09
Curtis Williams Curtis Williams is offline
Registered User
#0588 (Team 588)
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Jacksonville, FL
Posts: 122
Curtis Williams is on a distinguished road
Send a message via ICQ to Curtis Williams Send a message via AIM to Curtis Williams Send a message via MSN to Curtis Williams Send a message via Yahoo to Curtis Williams
Remember that p1_sw_top will be 1 the entire time the switch is pressed. So, if you hold it down for 1 second, the relay will change back and forth about 40 times. What I do is store a bit (i call it p1_sw_top_last) that stores the state of the button last cycle. When p1_sw_top &~ p1_sw_top_last , then the button has just been pressed, so perform actions. Try this out:

when declaring variables:
=================================
p1_sw_top_last VAR bit
p1_sw_top_last = 0

in the main loop:
=================================
if NOT (p1_sw_top &~ p1_sw_top_last) then skipThis1:
if relay1_rev then fwd1:
relay1_fwd = 0
relay1_rev = 1
goto skipthis
fwd1:
relay1_fwd = 1
relay1_rev = 0
skipThis1:
p1_sw_top_last = p1_sw_top

Im gonna be testing this out tomorrow, so I'm not sure if it works.