Launch of Linino.org
Launch of Linino.org
The digital IO shield allows you to add 16 more gpios to the already existing ones of your Linino board. The shield is equipped with 8 Leds, 4 Relays and 4 push buttons as follows:
DIGITAL-IO SHIELD | |||
---|---|---|---|
GPIO | OUTPUT | shield | NODEJS |
216 | gpio216 | push button 1 | SD0 |
217 | gpio217 | push button 2 | SD1 |
218 | gpio218 | push button 3 | SD2 |
219 | gpio219 | push button 4 | SD3 |
220 | gpio220 | SD4 | |
221 | gpio221 | SD5 | |
222 | gpio222 | SD6 | |
223 | gpio223 | SD7 | |
224 | gpio224 | Led 1 / Relay 1 | SD8 |
225 | gpio225 | Led 2 / Relay 2 | SD9 |
226 | gpio226 | Led 3 / Relay 3 | SD10 |
227 | gpio227 | Led 4 / Relay 4 | SD11 |
228 | gpio228 | Led 5 | SD12 |
229 | gpio229 | Led 6 | SD13 |
230 | gpio230 | Led 7 | SD14 |
231 | gpio231 | Led 8 | SD15 |
To enable the digitalIO shield you can run this command:
root@linino:~# echo digitalio > /sys/devices/mcuio/shield_register
If the shield registration is successful, you will be able to detect gpiochip216 in the following sysfs path :
root@linino:~# ls /sys/class/gpio/ export gpio22 gpiochip0 gpiochip216 gpio21 gpio23 gpiochip100 unexport
to enable the use of a given push button, you first have to export its correspondig gpio (i.e. push button 1 on the gpio 216):
root@linino:~# echo 216 > /sys/class/gpio/export
set the gpio direction in input mode:
root@linino:~# echo in > /sys/class/gpio/gpio216/direction
and then you can read the input value:
root@linino:~# cat /sys/class/gpio/gpio216/value 0
To read the push button state in nodejs, run the following script:
to enable the use of a given led, you first have to export its correspondig gpio (i.e. Led 5 on the gpio 228):
root@linino:~# echo 228 > /sys/class/gpio/export
set the gpio direction in output mode:
root@linino:~# echo out > /sys/class/gpio/gpio228/direction
and then turn the led on by running this command:
root@linino:~# echo 1 > /sys/class/gpio/gpio228/value
to enable the use of a given relay, you first have to export its correspondig gpio (i.e. Relay 1 on the gpio 224):
root@linino:~# echo 224 > /sys/class/gpio/export
set the gpio direction in output mode:
root@linino:~# echo out > /sys/class/gpio/gpio224/direction
then, you can change relay's state by writing “1” or “0” in the “value” field:
root@linino:~# echo 1 > /sys/class/gpio/gpio224/value