Push buttons/LED to initiate a command not working

im trying to use the LED/Buttons on the ABB to initiate a command:

[code] IF(butA = BUTTON_DOWN) and (prev_butA = BUTTON_UP) THEN

…command here
endif

;[ReadButtons] Reading input buttons from the ABB
ReadButtons:'Make P4-P6 inputs to read buttons. This turns the LEDs off briefly

input P4
input P5
input P6

prev_butA = butA
prev_butB = butB
prev_butC = butC

butA = IN4
butB = IN5
butC = IN6

return
;--------------------------------------------------------------------
;[WriteOutputs] Updates the state of the leds
WriteOutputs: 'Output LOW to each LED that should be on
IF ledA = 1 THEN
low p4
ENDIF
IF ledB = 1 THEN
low p5
ENDIF
IF ledC = 1 THEN
low p6
ENDIF
IF Eyes = 0 THEN
low cEyesPin
ELSE
high cEyesPin
ENDIF
return[/code]

when programming the Atom pro the A ~LED is on the others are off,
Once programmed the A and C LEDs flick fast while the B LED is on bright.
when i push A or C buttons they go bright and B stays Bright.

the command i give for pushing button A doesnt work. iv added a sound command.

You can’t make a decision on an input and read the input at the same time. You must read the input, then make a decision on what to do.

WriteOutputs: 'Output LOW to each LED that should be on ledA = pin4 IF ledA = 1 THEN low p4 ENDIF

ah, the “WriteOutputs” parts were already added to my code as pasted here. i just uncommented them. thought they would have been correct?! :open_mouth:

thanks jim.

Is it possible to perform an input read function using pre-defined pin numbers? I prefer to define pin functions in the beginning of my code so that I don’t need to keep track of which inputs/outputs go to which pin. An example of this is the code below for a servo control function. In this code I predefine the two servo pins so I can just refer to them as YServo and XServo in the HSERVO function and elsewhere throughout the program.

[code]YServo CON 2 ’ Y-axis servo
Xservo CON 3 ’ X-axis servo
pulseX VAR SWord
pulseY VAR SWord

pulseX = 0
pulseY = 0

enablehservo ’ Activate HSERVO function

HSERVO [XServo\pulseX, YServo\pulseY] ’ Send control pulses to servos[/code]

It doesn’t look like the ATOM will accept the following code however for reading from input pins:

[code]ButtonReset CON 13
Button_Reset VAR Byte

Button_Reset = ButtonReset
if (Button_Reset = 0) then
goto start
endif[/code]

Instead I’m forced to use the following code:

[code]Button_Reset VAR Byte

Button_Reset = in13
if (Button_Reset = 0) then
goto start
endif[/code]

Is there anyway to avoid the need to refer to specific pin locations when reading inputs?

I’ve tried all manner of things too. It looks like it’s just not possible. :frowning: