Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
AdamOutler
Old
#1  
AdamOutler's Avatar
Elite Recognized Developer - OP
Thanks Meter 7887
Posts: 4,717
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
Default GPIOs as Services

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.



Instructions:
1. Download this package http://forum.xda-developers.com/atta...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

Attached Files
File Type: gz GPIO-LED-Services.tar.gz - [Click for QR Code] (10.0 KB, 88 views)
I ignore PMs with questions that could be answered by searching. If you PM me, I probly won't respond.
Check out my developer pages. Add me to your circles on Google Plus.
The Following 8 Users Say Thank You to AdamOutler For This Useful Post: [ Click to Expand ]
 
NathanBookham
Old
#2  
NathanBookham's Avatar
Senior Member
Thanks Meter 151
Posts: 581
Join Date: Oct 2011
Location: Petersfield

 
DONATE TO ME
Default Re: GPIOs as Services

Great job! This will be useful!

Sent from my GT-S5830 using Tapatalk 2
Devices:
Samsung Galaxy Ace
Raspberry Pi Model B Revision 2

Visit my website @ Nathan Bookham's Blog or follow me on Twitter @inversesandwich.
If I helped you, hit the thanks button!
 
io53
Old
(Last edited by io53; 6th March 2013 at 02:18 PM.)
#3  
io53's Avatar
Senior Member
Thanks Meter 221
Posts: 595
Join Date: Oct 2010
Default Re: GPIOs as Services

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.
 
AdamOutler
Old
#4  
AdamOutler's Avatar
Elite Recognized Developer - OP
Thanks Meter 7887
Posts: 4,717
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
I haven't checked.
I ignore PMs with questions that could be answered by searching. If you PM me, I probly won't respond.
Check out my developer pages. Add me to your circles on Google Plus.
 
Contingency™
Old
#5  
Contingency™'s Avatar
Senior Member
Thanks Meter 429
Posts: 136
Join Date: May 2012
Location: 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.
 
NathanBookham
Old
#6  
NathanBookham's Avatar
Senior Member
Thanks Meter 151
Posts: 581
Join Date: Oct 2011
Location: Petersfield

 
DONATE TO ME
Default Re: GPIOs as Services

Quote:
Originally Posted by Contingency™ View Post
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.
I saw the root box on xda-tv. Looks great!

Sent from my GT-S5830 using Tapatalk 2
Devices:
Samsung Galaxy Ace
Raspberry Pi Model B Revision 2

Visit my website @ Nathan Bookham's Blog or follow me on Twitter @inversesandwich.
If I helped you, hit the thanks button!
 
Orkeren
Old
#7  
Orkeren's Avatar
Senior Member
Thanks Meter 52
Posts: 280
Join Date: Jan 2011
Location: Aabenraa
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
Phone: Sony Ericsson x10 mini pro
Tablet: Asus EeePad Transformer B50
Anybody got a danish dock for the tf101 for sale?
GPS: AsusGarmin A50
Random devices: HTC Herald, HTC Oxygen, Raspberry Pi
The Following User Says Thank You to Orkeren For This Useful Post: [ Click to Expand ]
 
aishiscool
Old
#8  
aishiscool's Avatar
Member
Thanks Meter 7
Posts: 83
Join Date: Apr 2012
Location: Melbourne
Default Re: GPIOs as Services

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
Quote:
Rajinikanth doesn't move at the speed of light. Light moves at the speed of Rajinikanth.
 
AdamOutler
Old
#9  
AdamOutler's Avatar
Elite Recognized Developer - OP
Thanks Meter 7887
Posts: 4,717
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
Quote:
Originally Posted by aishiscool View Post
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
You would want to use transistors or relays to drive them.
I ignore PMs with questions that could be answered by searching. If you PM me, I probly won't respond.
Check out my developer pages. Add me to your circles on Google Plus.
 
yahooguy
Old
#10  
Junior Member
Thanks Meter 0
Posts: 8
Join Date: Apr 2010
Location: Indianapolis
This will be handy while I figure out just what I can use my spare Pi for...

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...