About Buy News Guide Ideas
The phatIO project has finished, and I'm no longer selling ready made boards - but you're welcome to look around - send any questions to the email below

Back to Table of Contents


Conditions allow code to be executed based on either the digital or analogue input to a pin.

Note that conditions are tested each millisecond intervals, when a condition is triggered the code will be executed after any current LIO or fileaccess code has completed.

(pin_goes_low <pin> <code> ...)

(pin_goes_high <pin> <code> ...)

(pin_changes <pin> <code> ...)

When the given pin goes low, high or changes state respectively the remaining arguments are evaluated.

(pinmode 0 HIGH)
(pinmode 1 OUT)
(pin_goes_low 0 
	(keyboard "button pressed!")
	(setpin 1 1))

##(adc_goes_above <pin> <trigger_value> [reset_value] <code> ...)[adc_goes_above] ##(adc_goes_below <pin> <trigger_value> [reset_value] <code> ...)[adc_goes_below]

When the adc value goes above the trigger value (0..1024) the remaining arguments are evaluated. If the third argument is a non expression/list it is treated as a reset value - the condition will not trigger again until the adc value passes below/above that value.

(pinmode 11 ADC)
(pin_goes_below 100 800
	(keyboard "pin 11 at " (get_adc 11)))

Several examples in the Ideas section use conditions, including Basic ADC.

@Contact  |   Legal & Privacy  |    RSS  |   Development Twitter  |   Official Twitter
© phatIO 2012, All Rights Reserved.