2 Replies Latest reply on Nov 26, 2013 3:38 AM by arduino_4_life

    Toggling Arduino Pins from Linux

    Clayton Hofrock

      I want to toggle one of the Arduino header pins from within Linux. I have followed Sergey's example from his blog.



      I picked Digital Pin 4 (D4) because it is one of the pins that is not muxed, which should make it simpler.


      I used the below Linux commands to try light an LED connected to Pin D4, but nothing happens. Am I doing something wrong? Did I miss a step?


      #To Turn the Port On

      echo -n "28" > /sys/class/gpio/export


      #to Turn the Port as in Output

      echo -n "out" > /sys/class/gpio/gpio28/direction


      #turn on the pin

      echo -n "1" > /sys/class/gpio/gpio28/value




      Here is the output from my testing:

      root@clanton:~# #To Turn the Port On

      root@clanton:~# echo -n "28" > /sys/class/gpio/export


      root@clanton:~# #to Turn the Port as in Output

      root@clanton:~# echo -n "out" > /sys/class/gpio/gpio28/direction

      root@clanton:~# more /sys/class/gpio/gpio28/direction



      root@clanton:~# #turn on the pin

      root@clanton:~# echo -n "1" > /sys/class/gpio/gpio28/value

      root@clanton:~# more /sys/class/gpio/gpio28/value


        • 1. Re: Toggling Arduino Pins from Linux

          nope you're right- you found a bug


          To workaround this, simply add one more line to your list of commands;


          echo 28 > /sys/class/gpio/export

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

          echo strong > /sys/class/gpio/gpio28/drive

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

          this changes the pullup configuration for the pin.

          You can try this for any other pins that seemingly don't work.

          By any chance, did you load an image from the 0.8 Quark BSP release on to your board, and then revert back to 0.7.5 (the version which is here on maker.intel.com)?


          I'm guessing this is also why the LCD screens don't work as expected. Nice find!


          1 of 1 people found this helpful
          • 2. Re: Toggling Arduino Pins from Linux

            FYI, I just built myself an image from the 0.8 Quark BSP and this problem is not present.

            If you want to do the same, download the Quark BSP from here;




            you just need these two files-



            In the build guide, skip straight to step 4 (Kernel & root filesystem with Yocto)

            and do bitbake image-full to build a large image for SD (You can do image-spi if you want, but it takes a few extra steps- if you do image-full then all you need to worry about is step 4 of the guide).

            If you want the image to have sketch functionality and work with the IDE, then you need to pass the following arguments to the setup.sh script;

            ./setup.sh -e meta-clanton-galileo