Home Contents | # Query GPIO State | Gpio | Core4 Lua Event System

## SYNOPSIS

1. bits = gpio.inputs([group])
2. state = gpio.input([group, ]nr)
3. bits = gpio.outputs([group])
4. state = gpio.output([group, ]nr)
5. bits = gpio.dips()
6. state = gpio.dip(nr)

## DESCRIPTION

These commands query the state of digital input/output ports. In the simplest form, the parameter nr indicates the output number of a port on the controller itself.

gpio.dip() gpio.input() gpio.output() | Returns the current boolean state of the DIP-switch, input port or output port nr, respectively.
gpio.dips() gpio.inputs() gpio.outputs() | Returns the current state as an unsigned integer bit-mask. Bit 0 contains the first value, and so on.

## NOTES

On V4 architecture controllers, The first dip switch at nr 0 is always the "Debug Jumper".

## EXAMPLE

Both examples are equivalent.

> > >
if (gpio.dips() & 8) then print ("DIP 4 is on") end
> > >
if (gpio.dips(4)) then print ("DIP 4 is on") end

## SEE ALSO

gpio.blink, gpio.edge, gpio.out, gpio.pulse