View Single Post
  #2   Spotlight this post!  
Unread 27-01-2006, 20:14
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Digital I/O Help

There are two ways you can do what you want. The first is the easy way:
  1. Create either a global variable or a static local variable where you will store your count
  2. Somewhere in the 26.2 ms loop area, have an if statement which increments the variable if the digital io is pressed. IE:
    Code:
    if(digital_io_01 == 0) // Note that the inputs are pulled high, so when the sensor is indicating it is pressed, you are actually getting 0
        countVariable++;

The second way involves using interrupts and is slightly more difficult, but necessary if you are going to be getting digital IO state changes at a high rate. (An encoder on a drive wheel would be an example of something which typically needs interrutps.)
__________________