View Single Post
  #3   Spotlight this post!  
Unread 27-01-2006, 20:19
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,112
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: Digital I/O Help

The digital inputs on the RC will read as "1" when open, and "0" when grounded. They will directly detect contact closures to ground, such as a limit switch or an Allen-Bradley optical sensor.

If you want your code to count switch activations, you should remember that you only want to increment the count when the read value changes from 1 to 0.
Code:
  if (last_rc_dig_07 == 1 && rc_dig_07 == 0)
    switch_counter++;
  last_rc_dig_07 = rc_dig_07;