In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote: Lance, I would suggest using PIN instead of VAR when defining the SX pin aliases. Try something like this: [code] ' ====================================================================== ' ' ' ====================================================================== ' ---------------------------------------------------------------------- ' Program Description ' ---------------------------------------------------------------------- ' ---------------------------------------------------------------------- ' Device Settings ' ----------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "KEYPAD" ' ---------------------------------------------------------------------- ' IO Pins ' ---------------------------------------------------------------------- KeyA PIN RC.0 INPUT SCHMITT PULLUP ' Remote receiver A KeyB PIN RC.1 INPUT SCHMITT PULLUP ' Remote receiver B KeyC PIN RC.2 INPUT SCHMITT PULLUP ' Remote receiver C KeyD PIN RC.3 INPUT SCHMITT PULLUP ' Remote receiver D LED9 PIN RC.7 OUTPUT LED8 PIN RC.6 OUTPUT ' ---------------------------------------------------------------------- ' Constants ' ---------------------------------------------------------------------- Yes CON 0 ' active low input No CON 1 ' ---------------------------------------------------------------------- ' Variables ' ---------------------------------------------------------------------- theKey VAR Byte ' from keypad, 0 - 16 tmpB1 VAR Byte ' subroutine work vars tmpW1 VAR Word ' ====================================================================== PROGRAM Start ' ====================================================================== ' ---------------------------------------------------------------------- ' Subroutine Declarations ' ---------------------------------------------------------------------- GET_KEY SUB 0 ' get key from pad DELAY SUB 1, 2 ' delay in milliseconds ' ---------------------------------------------------------------------- ' Program Code ' ---------------------------------------------------------------------- Start: LOW LED9 LOW LED8 Main: theKey = GET_KEY ' get a key IF theKey > 0 THEN ' was a key pressed? HIGH LED9 DELAY 100 LOW LED9 ELSE HIGH LED8 DELAY 100 LOW LED8 ENDIF GOTO Main ' ---------------------------------------------------------------------- ' Subroutine Code ' ---------------------------------------------------------------------- ' ' Use: aByte = GET_KEY ' -- scans keyboard and places key value into 'aByte' GET_KEY: tmpB1 = 0 ' reset value IF KeyA = Yes THEN TmpB1 = 1 ENDIF IF KeyB = Yes THEN TmpB1 = 2 ENDIF IF KeyC = Yes THEN TmpB1 = 3 ENDIF IF KeyD = Yes THEN TmpB1 = 4 ENDIF RETURN tmpB1 ' --------------------------------------------------------------------- ' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 DELAY: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 RETURN ' ====================================================================== ' User Data ' ====================================================================== [/code] Bean ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=263052#m263071 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)