Pregunta

I am trying to setup up a output GPIO pin on my Nitrogen6X board, but I can't change the file value. I navigated to /sys/class/gpio/ and I exported my pin (GPIO18) with echo 18 > export. I was then able to change direction with the command echo out > direction and it seems like I should be able to change the value file the same way, with echo 1 > value, but this doesn't seem to be working. I am logged in as root and the permissions on both the direction file and the value file are the same: -rw-r--r-- 1 root root.

Does anyone have an idea why this would not be writing to this file?

Thanks so much for all of your help!

¿Fue útil?

Solución

The commands that you have listed should work, if the gpio number is correct. While I have not worked with Nitrogen6X in particular, I have found out that Linux GPIO pin numbers often do not match the labels on the board. I advice trying to find out the proper mapping experimentally by watching all possible GPIOs:

cd /sys/class/gpio
for x in `seq 1 128`; do echo $x > export; done

ground the pin in question via 10k resistor, run:

grep . gpio*/value > /tmp/values0

connect the pin in question to Vcc via 10k resistor, run:

grep . gpio*/value > /tmp/values1

diff the files, and pay attention which pin has changed.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top