いきよいで、LED Blinkを試み
まず pythonのインストール。
Python Install
メモリが限られているので、python-lightがいいらしい。
root@Omega-6F83:~# opkg update
root@Omega-6F83:~# opkg install python-light
Installing python-light (2.7.13-4) to root…
Downloading http://repo.onion.io/omega2/packages/packages/python-light_2.7.13-4_mipsel_24kc.ipk
Installing python-base (2.7.13-4) to root…
Downloading http://repo.onion.io/omega2/packages/packages/python-base_2.7.13-4_mipsel_24kc.ipk
Installing libffi (3.2.1-2) to root…
Downloading http://repo.onion.io/omega2/packages/packages/libffi_3.2.1-2_mipsel_24kc.ipk
Installing libbz2 (1.0.6-2) to root…
Downloading http://repo.onion.io/omega2/packages/base/libbz2_1.0.6-2_mipsel_24kc.ipk
Configuring python-base.
Configuring libffi.
Configuring libbz2.
Configuring python-light.
root@Omega-6F83:~#
Onion GPIO Python Module
GPIOを制御するモジュール
root@Omega-6F83:~# opkg install python-light pyOnionGpio
Package python-light (2.7.13-4) installed in root is up to date.
Installing pyOnionGpio (0.1-1) to root…
Downloading http://repo.onion.io/omega2/packages/onion/pyOnionGpio_0.1-1_mipsel_24kc.ipk
Configuring pyOnionGpio.
root@Omega-6F83:~#
LED Blink
いよいよLED点滅のプログラム
GPIO1にLEDと抵抗を繋ぐ。
import time import onionGpio gpioNum = 1 gpioObj = onionGpio.OnionGpio(gpioNum) ## set to output status = gpioObj.setOutputDirection(0) ## alternate the value loop = 1 value = 0 while loop == 1: # reverse the value if value == 0: value = 1 else: value = 0 # set the new value status = gpioObj.setValue(value) print 'GPIO%d set to: %d'%(gpioNum, value) time.sleep(1)
一秒ことにLED点滅が確認できた。
参考:
- https://docs.onion.io/omega2-docs/gpio-python-module.html#gpio-python-module