' ========================================================================= ' ' File....... Pushbutton_Test.BS2 ' Purpose.... Simple checkout of pushbutton circuits ' Author..... Parallax ' E-mail..... support@parallax.com ' Started.... ' Updated.... 11 AUG 2003 ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' Uses editor DEBUG screen to check button inputs. ' -----[ Revision History ]------------------------------------------------ ' -----[ I/O Definitions ]------------------------------------------------- Button1 PIN 8 Button2 PIN 12 ' -----[ Constants ]------------------------------------------------------- ' -----[ Variables ]------------------------------------------------------- btnVal VAR Bit ' state of a button ' -----[ EEPROM Data ]----------------------------------------------------- ' -----[ Initialization ]-------------------------------------------------- Setup: DEBUG CLS, "Button Test" ' -----[ Program Code ]---------------------------------------------------- Main: DEBUG CRSRXY, 0, 2 btnVal = Button1 ' get state of button 1 DEBUG "Button on P8.... ", BIN1 btnVal ' display it GOSUB Show_State btnVal = Button2 ' get state of button 2 DEBUG "Button on P12... ", BIN1 btnVal ' display it GOSUB Show_State GOTO Main ' do it again ' -----[ Subroutines ]----------------------------------------------------- Show_State: IF (btnVal = 1) THEN DEBUG " (Pressed)", CLREOL, CR ELSE DEBUG " (Not Pressed)", CLREOL, CR ENDIF RETURN