GPIO Example #1

Hello

We try the GPIO Example#1 , link as below,

https://up-community.org/wiki/Pinout

GPIO Example #1

$ sudo echo 26 > /sys/class/gpio/export
the error is --> bash: /sys/class/gpio/export: Permission denied

$sudo chmod 777 /sys/class/gpio/export

$ sudo echo 26 > /sys/class/gpio/export
the error is --> echo: write error: Invalid argument

$ sudo sh –c ‘echo 26 > /sys/class/gpio/export’

The error is --> sh: echo:I/O error


Any suggestions?

Comments

  • Kurt
    Kurt New Member Posts: 146 ✭✭
    Seems a bit different that the company is asking how to do this for it's own board?

    Maybe just testing out Wiki stuff?

    Don't know what OS? Do you have the right things installed?

    With me on Ubuntu 16.04 with new kernel that has support. The only luck I have had is to do something like:
    sudo sh
    
    It asks for pasword, and gives a command prompt.
    I can then enter the commands as shown on the wiki...

    Or you can try installing MRAA, there are a few threads that talk about this. Once you install MRAA, I did from source and did the build, you can then go run the example code. But for example you need to run it using sudo. Also in the example the pin number you pass to the MRAA pins is the pin number in the connector, not the Linux(RPI) pin number.

    More information in my recent thread about MRAA
  • Pierre Laurent
    Pierre Laurent New Member Posts: 6
    redirection ">" is handled by the parent shell, not the process under sudo.

    the solution is quite simple and is part of shell programming rules. see the double quotes here.

    sudo sh -c "echo 26 > /sys/class/gpio/export"