That worked, thanks.
In case anyone else needs it, this is the working config:
config.g
: External trigger inputs
; these are the 4 push buttons on my front panel, 1 (top) - 4 (bottom)
M950 J1 C"^duex.gp1" ; define input pin 1 using GPIO1 and enable pullup
M581 P1 T2 S0 R0 ; associate input pin 1 with trigger2.g (top switch)
M950 J2 C"^duex.gp2" ; define input pin 2 using GPIO2 and enable pullup
M581 P2 T3 S0 R0 ; associate input pin 2 with trigger3.g
M950 J3 C"^duex.gp3" ; define input pin 3 using GPIO3 and enable pullup
M581 P3 T4 S0 R0 ; associate input pin 3 with trigger4.g
M950 J4 C"^duex.gp4" ; define input pin 4 using GPIO4 and enable pullup
M581 P4 T5 S0 R0 ; associate input pin 4 with trigger5.g (bottom switch)
; output ports
M950 P0 C"duex.e4heat" ; assign output pin 0 to E4 on the duex5 - enclosure lights
;M950 P1 C"duex.e5heat" ; assign output pin 1 to E5 on the duex5 - bed lights
trigger5 file
; Trigger number 0 causes an emergency stop as if M112 had been received.
; Trigger number 1 causes the print to be paused as if M25 had been received.
; Any trigger number # greater than 1 causes the macro file sys/trigger#.g to be executed.
; trigger5 runs if switch 4 pressed", turns the LED connected to E4 on/off
; checks state of output P0 and reverses the state
if {state.gpOut[0].pwm = 1}
M42 P0 S0 ; turn off output pin 0
elif {state.gpOut[0].pwm = 0}
M42 P0 S1 ; turn on output pin 0
else
echo {"Pin 0 value is" ^ state.gpOut[0].pwm}
M42 P0 S0