4 Replies Latest reply on Oct 9, 2014 1:24 PM by AlexT_Intel

    GPIO usage in bash

    shb

      Hello,

      i ve tried to activate the gpio's with the bash

      echo 12 > /sys/class/gpio/export
      echo out > /sys/class/gpio/gpio12/direction
      echo 1 > /sys/class/gpio/gpio12/value
      
      

       

      this is how it is described for raspberry pi or beagelbone black. everthing is fine, no errors but my led does not light.

      I am using the arduino breakout board. i think the gpio 12 is for the pin 3 on breakout. like it is described in the manual for the breakoutboard.

       

      I am also not sure which of the other pins on the breakout are the gpio on the edison.

       

      regardes

       

      shb

        • 1. Re: GPIO usage in bash
          DiegoV_Intel

          Hi shb,

           

          I'll recommend you to check this post: Mapping for digital and analog Arduino pins. I think you might find it very helpful.

           

          Check it and let us know if this answered your question. Have a nice day!

           

          Regards,

          Diego.

          • 2. Re: GPIO usage in bash
            David_J_Hunt

            Each pin has many modes, and there are multiple things on the board that can affect the pin, so they all need to be set up before you can get an output toggling. This is normally hidden from the end-user, as the Arduino IDE  for Intel Edison does. All the following multiplexing (pin mapping) can be deduced from the code in the Arduino IDE.

             

            For pin 3, try this ...

             

            # export the relevant pins

            echo 214 > /sys/class/gpio/export

            echo 12 > /sys/class/gpio/export

            echo 251 > /sys/class/gpio/export

            echo 219 > /sys/class/gpio/export

             

            #Set up the muxing

            echo mode0 > /sys/kernel/debug/gpio_debug/gpio12/current_pinmux

            echo low > /sys/class/gpio/gpio214/direction

            echo high > /sys/class/gpio/gpio251/direction

            echo high > /sys/class/gpio/gpio219/direction

            echo 1 > /sys/class/gpio/gpio251/value 

            echo 1 > /sys/class/gpio/gpio219/value 

            echo out > /sys/class/gpio/gpio12/direction

            echo 0 > /sys/class/gpio/gpio12/value  

            echo high > /sys/class/gpio/gpio214/direction

             

            # Now Toggle the pin

            echo 1 > /sys/class/gpio/gpio12/value

            sleep 1

            echo 0 > /sys/class/gpio/gpio12/value

            sleep 1

            echo 1 > /sys/class/gpio/gpio12/value

            • 3. Re: GPIO usage in bash
              shb

              thank you very much,

              this works a "little bit". i 've tried your code the led lights just a little bit, like it is used with pwm.

               

              Because i am a lazy, i ve a work around for this setup.

              I write a sketch and set the pins how i need them and change the pins with echo 1 > ...

               

              regards

              shb

              • 4. Re: GPIO usage in bash
                AlexT_Intel

                Here's the script I used for my Edison demo project: https://github.com/alext-mkrs/edison-mon-sys/blob/master/home/motion/scripts/gpio_blink.sh

                 

                Worked fine with D7 pin and the LED was bright enough.