User manual

Table Of Contents
628
mikoC PRO for PIC32
MikroElektronika
Miscellaneous Libraries
- Button Library
- Conversions Library
- PrintOut Library
- Setjmp Library
- Sprint Library
- Time Library
- Trigonometry Library
Button Library
The Button Library provides routines for detecting button presses and debouncing (eliminating the inuence of contact
ickering upon pressing a button).
Library Routines
- Button
Button
Prototype
unsigned int Button(unsigned int *port, unsigned int pin, unsigned int time,
unsigned int active_state);
Description The function eliminates the inuence of contact ickering upon pressing a button (debouncing). The
Button pin is tested just after the function call and then again after the debouncing period has expired.
If the pin was in the active state in both cases then the function returns 255 (true).
Parameters - port: button port address
- pin: button pin
- time: debouncing period in milliseconds
- active_state: determines what is considered as active state. Valid values: 0 (logical zero) and
1 (logical one)
Returns -255 if the pin was in the active state for given period.
- 0 otherwise
Requires Nothing.
Example
if (Button(&PORTD, 0, 1, 1))
PORTB = 0xFF;
...
Notes None.