GPIOs as Services

Search This thread

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
Hey guys, I put this simple package together which allows you to turn on and off GPIOs from the command line as services. This can be used for all sorts of things.
sy4fhh.jpg



Instructions:
1. Download this package http://xdaforums.com/attachment.php?attachmentid=1780219&stc=1&d=1362453406
2. unTar.Gz it to the root directory of your Raspberry Pi. There's 6 files which go into /etc/init.d. The files are InitGPIO, led0, led1, led2, led3, and led4. These services control GPIOs 0, 1, 4, 14, and 15. See the chart below for more information.
3. Connect LEDs with 100 ohm resistors to the corresponding GPIOs using an old IDE hard disk cable.

Use
Initialize the GPIOs first
Code:
service InitGPIO start
Turn on LEDs with
Code:
service led0 start
service led1 start
service led2 start
service led3 start
service led4 start

Turn off LEDs with
Code:
service led0 stop
service led1 stop
service led2 stop
service led3 stop
service led4 stop


k3s3p.jpg
 

Attachments

  • GPIO-LED-Services.tar.gz
    10 KB · Views: 272

io53

Senior Member
Oct 25, 2010
772
254
Seems like a neat solution. How fast can you toggle the pins? I can check with a scope if you haven't already :).

Sent from my Nexus 4 using xda premium

Edit: It hit me that I could just look at the source, doh. As it's using echo you should get about 3.4khz.
 
Last edited:

Contingency™

Senior Member
May 9, 2012
135
433
Oklahoma
Have you already posted specs and software for your "Root All The Things Box" if not, are you going to as I'd like to build one myself.
 

Orkeren

Senior Member
Jan 11, 2011
292
63
København
thanks for the services :) I wanted to test some things with the GPIOs (controlling a DC motor with an H-bridge) and I was to lacy to do the python programming :) so your binary were really convenient :D
 
  • Like
Reactions: AdamOutler

aishsingh

Senior Member
Apr 19, 2012
83
7
OnePlus 3T
OnePlus 7T Pro
Thanks for your work :thumbup:
Just to confirm, can I use this to control DC motors instead of leds? and if so do I have to change anything?

Sent from my HTC Vision using xda app-developers app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Hey guys, I put this simple package together which allows you to turn on and off GPIOs from the command line as services. This can be used for all sorts of things.
    sy4fhh.jpg



    Instructions:
    1. Download this package http://xdaforums.com/attachment.php?attachmentid=1780219&stc=1&d=1362453406
    2. unTar.Gz it to the root directory of your Raspberry Pi. There's 6 files which go into /etc/init.d. The files are InitGPIO, led0, led1, led2, led3, and led4. These services control GPIOs 0, 1, 4, 14, and 15. See the chart below for more information.
    3. Connect LEDs with 100 ohm resistors to the corresponding GPIOs using an old IDE hard disk cable.

    Use
    Initialize the GPIOs first
    Code:
    service InitGPIO start
    Turn on LEDs with
    Code:
    service led0 start
    service led1 start
    service led2 start
    service led3 start
    service led4 start

    Turn off LEDs with
    Code:
    service led0 stop
    service led1 stop
    service led2 stop
    service led3 stop
    service led4 stop


    k3s3p.jpg
    1
    thanks for the services :) I wanted to test some things with the GPIOs (controlling a DC motor with an H-bridge) and I was to lacy to do the python programming :) so your binary were really convenient :D