Button Library
The Button Library provides routines for detecting button presses and debouncing (eliminating the influence of contact flickering upon pressing a button)
Library Routines
Button
| Prototype |
function Button(var port : byte; pin, time, active_state : byte) : byte; |
|---|---|
| Returns |
|
| Description |
Function eliminates the influence of contact flickering upon pressing a button (debouncing). Parameter |
| Requires |
Button pin must be configured as input. |
| Example |
Example reads RB0, to which the button is connected; on transition from 1 to 0 (release of button), PORTD is inverted:
while true do
begin
if Button(PORTB, 0, 1, 1) then oldstate := 255;
if oldstate and Button(PORTB, 0, 1, 0) then
begin
PORTD := not(PORTD);
oldstate := 0;
end;
end;
|
What do you think about this topic ? Send us feedback!



