Wiki source code of Control Gateway GPIOs & LEDs
Version 12.1 by Edwin Chen on 2022/05/07 11:28
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}} | ||
2 | {{toc/}} | ||
3 | {{/box}} | ||
4 | |||
5 | = Products LEDs Mapping = | ||
6 | |||
7 | {{velocity}} | ||
8 | $xwiki.ssfx.use("js/xwiki/table/table.css") | ||
9 | $xwiki.jsfx.use("js/xwiki/table/tablefilterNsort.js", true) | ||
10 | {{/velocity}} | ||
11 | |||
12 | (% class="doOddEven filterable grid sortable" id="tableid" %) | ||
13 | (% class="sortHeader" %)|=Model|=Global LED|=PWR LED | ||
14 | |LPS8|GPIO28(BLUE),GPIO21(RED),GPIO22(GREEN)|+3.3v] | ||
15 | | | | ||
16 | |||
17 | = Control LEDs & GPIOs = | ||
18 | |||
19 | == OpenWrt Base OS == | ||
20 | |||
21 | (% class="box infomessage" id="HControlanGeneralGPIO:" %) | ||
22 | ((( | ||
23 | **Control a General GPIO:** | ||
24 | |||
25 | **echo 18 > /sys/class/gpio/export** ~/~/ Export gpio 18 so we can use it | ||
26 | **echo "high" > /sys/class/gpio/gpio18/direction** ~/~/ Set direction to out and | ||
27 | set level to high. Use "low" to set direction to output and level to low | ||
28 | |||
29 | **echo 0 > /sys/class/gpio/gpio18/value** ~/~/ Set output to 0 or 1 | ||
30 | **echo "in" > /sys/class/gpio/gpio18/direction** ~/~/ Set GPIO18 as input | ||
31 | |||
32 | **cat /sys/class/gpio/gpio18/value** ~/~/ Get GPIO18 value if set input | ||
33 | ))) | ||
34 | |||
35 | (% class="box infomessage" %) | ||
36 | ((( | ||
37 | **Control a GPIO already exported as SYSTEM LEDs .** | ||
38 | **echo 1 > /sys/class/leds/dragino2\:red\:system/brightness** ~/~/ Turn On LED dragino2:red:system | ||
39 | **echo 0 > /sys/class/leds/dragino2\:red\:system/brightness** ~/~/ Turn off LED dragino2:red:system | ||
40 | ))) | ||
41 | |||
42 | |||
43 | Reference: [[http:~~/~~/www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#gpio-sysfs>>url:http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#gpio-sysfs]] |