' * Project name:
' Button_Test
' * Copyright:
' (c) Mikroelektronika, 2005.
' * Description:
' This code demonstrates how to use Button library. Program toggles LEDs
' on PORTD, upon falling edge on PORTB's RB1 pin.
' * Test configuration:
' MCU: PIC16F877A
' Dev.Board: EasyPic4
' Oscillator: HS, 08.0000 MHz
' Ext. Modules: -
' SW: mikroBasic v6.0
' * NOTES:
' - In order to work properly, in this example, ports B and D must have pull down
' resistors, also jumper jp20 on EasyPic4 board has to be in VCC position (that is,
' the voltage level to be applied when a button is pressed should be high (VCC)).
program Button_Test
dim oldstate as byte
main:
oldstate = 0
TRISB = 0xFF
TRISD = 0
PORTD = 0x0F
while true
if (Button(PORTB, 1, 1, 1)) then
oldstate = 1
end if
if (oldstate = 1) and (Button(PORTB, 1, 1, 0)) then
PORTD = not PORTD
oldstate = 0
end if
wend
end.