Working with discrete inputs in Linux

The discrete input can be in one of two states:

Status

Description

0

Input open (not connected)

1

Input is shorted to the common wire (GND)

Initialization:

Note

By default in Armbian Linux the GPIO pins are configured to sysfs mode at system boot and no additional configuration is required.

cd /sys/class/gpio
echo 472 > export
echo in > gpio472/direction

If you need to invert the input logic:

echo 1 > gpio472/active_low

Read the state of the digital input:

cat gpio472/value