Control Gateway GPIOs & LEDs

Version 10.1 by Edwin Chen on 2022/05/07 11:24
Warning
For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Contents

Products LEDs MappingFailed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [xwiki:Main.Control Gateway GPIOs & LEDs.WebHome]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

ModelPhoto
LHT65NLHT65N_00.jpg
  

Control LEDs & GPIOs

OpenWrt Base OS

Control a General GPIO:

echo 18 > /sys/class/gpio/export     // Export gpio 18 so we can use it
echo "high" > /sys/class/gpio/gpio18/direction   //  Set direction to out and
set level to high. Use "low" to set direction to output and level to low

echo 0 > /sys/class/gpio/gpio18/value    // Set output to 0 or 1
echo "in" > /sys/class/gpio/gpio18/direction  // Set GPIO18 as input

cat  /sys/class/gpio/gpio18/value  // Get GPIO18 value if set input

Control a GPIO already exported as SYSTEM LEDs .
echo 1 > /sys/class/leds/dragino2\:red\:system/brightness  // Turn On LED dragino2:red:system
echo 0 > /sys/class/leds/dragino2\:red\:system/brightness  // Turn off LED dragino2:red:system

Reference: http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#gpio-sysfs