I recently acquired Cubieboard (a10), put Debian (Cubian) there with gpio_sunxi installed, but had absolutely no idea how to work with GPIO, after the “tinkering” day I managed to manage and read data from GPIO through the commands:
echo 17 > /sys/class/gpio/export //Создаём pin с номером 17 echo out > /sys/class/gpio/gpio17_pg9/direction //Определяем его тип echo 1 > /sys/class/gpio/gpio17_pg9/value //Включаем его Или cat /sys/class/gpio/gpio17_pg9/value //Читаем включен или выключен pin
Everything works fine, but there is a certain distance calculation sensor, the principle of its operation:
We define the first pin as an output, the second as an input.
Turn on the first pin and wait for receiving the signal on the second.
The time after which the signal from the second pin will come is the distance.
But, since I worked through SSH, I can not count the time.
You can simply read / write this value (/ sys / class / gpio / gpio17_pg9 / value) to nodejs
via nodejs
, for example, but this is stupid and inaccurate.
The question itself:
How can I track the receipt of a signal (without a blunt cyclical opening of the file) and perform some kind of action, say, just display this time on the screen?