View Single Post
  #4   Spotlight this post!  
Unread 18-02-2005, 23:12
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Double Solenoid Help

To fix your code, you also need to make sure that you only process the change once each time the switch is activated.
Code:
  last_trig = 0;
  ...
  if (p3_sw_trig ==1 && last_trig == 0 && pnu == 0)
  {
    ...
    pnu += 1;
  }
  if (p3_sw_trig == 1 && last_trig == 0 && pnu == 1)
  {
    ...
    pnu = 0;
  }
  last_trig = p3_sw_trig;