Datasheet

BUTTON LIBRARY
The Button library contains miscellaneous routines useful for a project development.
External dependencies of Button Library
Library Routines
- Button
Button
476
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
The following variable
must be defined in all
projects using Button
library:
Description: Example :
dim Button_Pin as
sbit sfr external
Declares button pins.
dim Button_Pin as
sbit at PINB.B0
dim
Button_Pin_Direction
as sbit sfr external
Declares direction of the
button pin.
dim
Button_Pin_Direction
as sbit at DDRB.B0
Prototype
sub function Button(dim time_ms as byte, dim active_state as
byte) as byte
Returns
- 255 if the pin was in the active state for given period.
- 0 otherwise
Description
The function eliminates the influence of contact flickering upon pressing a but-
ton (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 :
-
time_ms : debouncing period in milliseconds
- active_state: determines what is considered as active state. Valid values: 0
(logical zero) and 1 (logical one)
Requires
Global variables :
-
Button_Pin: Button pin line
- Button_Pin_Direction: Direction of the button pin
must be defined before using this function.