Abl-electronic PIC Microcontrollers PIC16 Uživatelský manuál Strana 288

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 312
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 287
Util library contains miscellaneous routines useful for project development.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
280
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Util Library
Prototype
char Button(char *port, char pin, char time, char active_state);
Returns Returns 0 or 255.
Description Function eliminates the influence of contact flickering upon pressing a button (debounc-
ing).
Parameters
port and pin specify location of the button; parameter time specifies the
minimum time pin has to be in active state in order to return TRUE; parameter
active_state can be either 0 or 1, and it determines if 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);
Button
Zobrazit stránku 287
1 2 ... 283 284 285 286 287 288 289 290 291 292 293 ... 311 312

Komentáře k této Příručce

Žádné komentáře