2013/10/17

RPi-GPIO Cmd try out

Finally I’ve successfully TURN On & Off 3 LED lights on the breadboard.


Major road blocks are:



  1. Have no idea of which pin is which, say which is 25 pin.

  2. Don’t know if the LED is connected the right way.

  3. Strangely the echo command somehow not permitted by RPi.


Answer for Q1, we need multimeter to make sure which pin connect to which line. I’m using a bus to connect all pins to breadboard so this must be checked.


Answer for Q2, with help from Levy I realize the current should be set to flow from pin 25 to GND , not from pin 25 to the negative on the board.


Answer for Q3, it seems the cmd should be entered while you’re at root directory, like:



root@rpi:/# echo "1" > /sys/class/gpio/gpio25/value

So, the whole steps are as followed:



  1. Say you want to play with pin #25, then enter this, which will create corresponding files & directories needed in the export/:

    root@rpi:/sys/class/gpio# echo 25 > export

  2. Enter this line (don’t know what it means but without this cmd you won’t succeed)

    root@rpi:/sys/class/gpio# echo out > /sys/class/gpio/direction

  3. Then you could start turn on or off that LED installed:

    //Turn LED On @ pin #25
    root@rpi:/sys/class/gpio# echo 1 > /sys/class/gpio/gpio25/value
    //Turn LED Off @ pin #25
    root@rpi:/sys/class/gpio# echo 0 > /sys/class/gpio/gpio25/value



I’m referencing the book of Get Started with Raspberry Pi and this Instrctable tutorial. Big difference is the book didn’t mention the step 2 above, which I think it’s a setback for me. Now I could move on to more fun! Hope you also did it!



blue LED on pin #9 and green LED #17



red LED off on pin # 25






via Tumblr http://cyberrob.tumblr.com/post/64285566830

沒有留言: