In SX Microcontrollers, SX/B Compiler and SX-Key Tool, LanceRasmussen wrote: I have a remote device that outputs 5v as long as the remote button is held. There's 4 buttons. For the moment, I'm simply trying to trip an led on for each button while its pressed to know its being pressed. I split off the output of the buttons to the SX to go to another set of LED's to know the remote is actually firing ok. I only really programmed for one button just to see what was going on. The LED's from direct, fire great. The SX, however, doesn't seem to fire them properly. Script as follow. Input/Suggestions welcome. ' ========================================================================= ' ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "KEYPAD" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- KeyA VAR RC.0 ' Remote receiver A KeyB VAR RC.1 ' Remote receiver B KeyC VAR RC.2 ' Remote receiver C KeyD VAR RC.3 ' Remote receiver D PLP_Keys VAR PLP_C LED9 VAR RC.7 LED8 VAR RC.6 ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Yes CON 0 ' active low input No CON 1 ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- theKey VAR Byte ' from keypad, 0 - 16 tmpB1 VAR Byte ' subroutine work vars tmpB2 VAR Byte 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: INPUT RC = %00001111 LVL_C = %00001111 ST_C = %00001111 'PLP_C = %00001111 OUTPUT LED9 OUTPUT LED8 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 KeyA = 1 ' activate Remote KeyB = 1 ' activate Remote KeyC = 1 ' activate Remote KeyD = 1 ' activate Remote PLP_Keys = %00001111 ' pull-up input pins 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 ' ========================================================================= ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=263052 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)