Professional Documents
Culture Documents
Button Library
The Button library contains miscellaneous routines useful for a project development.
Library Routines
Button
Button
Returns
255 if the pin was in the active state for given period.
0 otherwise
Parameter port specifies the location of the button; parameter pin is the
pin number on designated port and goes from 0..7; parameter time is a
debounce period in milliseconds; parameter active_state can be either
0 or 1, and it determines if the button is active upon logical zero or
logical one.
Example Example reads RB0, to which the button is connected; on transition from
1 to 0 (release of button), PORTD is inverted:
do {
if (Button(&PORTB, 0, 1, 1)) oldstate = 1;
if (oldstate && Button(&PORTB, 0, 1, 0)) {
PORTD = ~PORTD;
oldstate = 0;
}
} while(1);
mk:@MSITStore:C:\Program%20Files%20(x86)\Mikroelektronika\mikroC%20PRO%20fo... 9/9/2010