Battery Charged in 30 Seconds? Maybe in 2016

Phones and tablets are getting more and more power hungry with each passing generation. Their … more

ZArchive Manages Your File Archives

Today smartphones are quite powerful devices that can handle multiple processes at once. In fact, some of … more

Regain Double Tap to Wake Functionality on the Nexus 6

A few months ago, Google announced its newest flagship device, the Nexus 6, alongside … more

Clean Your Recent Apps – XDA Xposed Tuesday

In this day and age, you have quite a few apps installed and running on your Android … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

GPIOs as Services

OP AdamOutler

5th March 2013, 04:22 AM   |  #1  
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, 125 views)
The Following 8 Users Say Thank You to AdamOutler For This Useful Post: [ View ]
5th March 2013, 08:59 PM   |  #2  
InverseSandwich's Avatar
Senior Member
Flag Hampshire
Thanks Meter: 153
 
580 posts
Join Date:Joined: Oct 2011
Donate to Me
More
Re: GPIOs as Services
Great job! This will be useful!

Sent from my GT-S5830 using Tapatalk 2
6th March 2013, 03:13 PM   |  #3  
io53's Avatar
Senior Member
Thanks Meter: 257
 
758 posts
Join Date:Joined: Oct 2010
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.
Last edited by io53; 6th March 2013 at 03:18 PM.
7th March 2013, 01:00 AM   |  #5  
Contingency™'s Avatar
Senior Member
Flag Oklahoma
Thanks Meter: 434
 
135 posts
Join Date:Joined: May 2012
More
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.
7th March 2013, 09:36 PM   |  #6  
InverseSandwich's Avatar
Senior Member
Flag Hampshire
Thanks Meter: 153
 
580 posts
Join Date:Joined: Oct 2011
Donate to Me
More
Re: GPIOs as Services
Quote:
Originally Posted by Contingency™

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
22nd March 2013, 10:26 AM   |  #7  
Orkeren's Avatar
Senior Member
Flag København
Thanks Meter: 65
 
292 posts
Join Date:Joined: Jan 2011
More
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: [ View ]
24th March 2013, 02:00 AM   |  #8  
aishiscool's Avatar
Member
Flag Melbourne
Thanks Meter: 7
 
83 posts
Join Date:Joined: Apr 2012
More
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
24th March 2013, 06:55 AM   |  #9  
Quote:
Originally Posted by aishiscool

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.
26th March 2013, 05:27 AM   |  #10  
Junior Member
Flag Indianapolis
Thanks Meter: 0
 
8 posts
Join Date:Joined: Apr 2010
More
This will be handy while I figure out just what I can use my spare Pi for...

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes