GPIO on OpenWrt

在树莓派上安装了OpenWrt系统, 对右下角两个GPIO进行控制.

  • GPIO 20 - INPUT - BUTTON
  • GPIO 21 - OUTPUT - LED

# install package
$ opkg update
$ opkg install gpioctl-sysfs

# output mode
$ echo 21 > /sys/class/gpio/export
$ gpioctl dirout 21
$ gpioctl set 21
$ gpioctl clear 21
$ echo 21 > /sys/class/gpio/unexport

# input mode
$ echo 20 > /sys/class/gpio/export
$ gpioctl dirin 20
$ gpioctl get 20
$ gpioctl get 20
$ echo 20 > /sys/class/gpio/unexport