Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,739,482 Members 54,177 Now Online
XDA Developers Android and Mobile Development Forum

GPIOs as Services

Tip us?
 
AdamOutler
Old
#1  
AdamOutler's Avatar
Recognized Developer - OP
Thanks Meter 9555
Posts: 5,176
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:
Select Code
service InitGPIO start
Turn on LEDs with
Code:
Select Code
service led0 start
service led1 start
service led2 start
service led3 start
service led4 start
Turn off LEDs with
Code:
Select 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, 124 views)
Flash with Odin on Windows, Linux and Mac. Use JOdin3, Available in a web browser or offline
Check out my developer pages. Add me to your circles on Google Plus.
Wanna see the longest Linux BASH script ever made? click here.
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 153
Posts: 579
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 257
Posts: 757
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
Recognized Developer - OP
Thanks Meter 9555
Posts: 5,176
Join Date: Feb 2011
Location: Louisiana

 
DONATE TO ME
I haven't checked.
Flash with Odin on Windows, Linux and Mac. Use JOdin3, Available in a web browser or offline
Check out my developer pages. Add me to your circles on Google Plus.
Wanna see the longest Linux BASH script ever made? click here.
 
Contingency™
Old
#5  
Contingency™'s Avatar
Senior Member
Thanks Meter 434
Posts: 135
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 153
Posts: 579
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 65
Posts: 292
Join Date: Jan 2011
Location: 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
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
Recognized Developer - OP
Thanks Meter 9555
Posts: 5,176
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.
Flash with Odin on Windows, Linux and Mac. Use JOdin3, Available in a web browser or offline
Check out my developer pages. Add me to your circles on Google Plus.
Wanna see the longest Linux BASH script ever made? click here.
 
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...

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Return to Outer Space Outer Space with Ship Up Game

Since the release of Flappy Birds, we’ve had the “fortune” to see … more

Device Review: OnePlus One

Seemingly every day, there are a bunch of new devices being released. Some are budget devices and some are … more

Browse the Internet with the Innovative Atlas Web Browser

For the most part, Chrome, Firefox, and Dolphin Browser have no real rivals among … more

Choose from Over a Thousand Battery Styles with 3Minit Battery Mod

The battery style in stock Android looks pretty dull. It doesn’t … more