User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

GPIO via bash??

Thu Oct 25, 2012 11:15 pm

Is it possible to read or write the pins on the GPIO using bash scripts or does it really have to be implemented using python or c++??

Richard S.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: GPIO via bash??

Thu Oct 25, 2012 11:18 pm

yes you can - I'll look it up and get back to you....

User avatar
joan
Posts: 15372
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO via bash??

Fri Oct 26, 2012 7:01 am

Examples for various languages are given here http://elinux.org/Rpi_Low-level_peripherals

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: GPIO via bash??

Fri Oct 26, 2012 10:12 am

Thanks, I just managed to toggle my GPIO pin via bash with the minimum amount of effort without the need of a compiler. :)

I guess if I wanted to implement this in Free Pascal all I need to do is treat the GPIO pins as if I was to read / write files or am I wrong??

Richard S.

User avatar
gordon@drogon.net
Posts: 2023
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website Twitter

Re: GPIO via bash??

Fri Oct 26, 2012 12:52 pm

redhawk wrote:Is it possible to read or write the pins on the GPIO using bash scripts or does it really have to be implemented using python or c++??

Richard S.
Absolutely!

first, get my wiringPi library:

Code: Select all

cd
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
then use the 'gpio' command:

Code: Select all

gpio mode 0 out
gpio write 0 1
etc.

use the -g flag if you want to use the BCM_GPIO numbers, otherwise it uses the wiringPi pin numbers.

0 -> 17
1- > 18
2 -> 21 or 27 if on a rev 2 board.

(stick to wiringPi numbers and you'll never need to change code)

Pinouts here: https://projects.drogon.net/raspberry-pi/wiringpi/pins/

Examples here:

Code: Select all

git clone git://git.drogon.net/ladder
and look at tuxx.sh

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
tedhale
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
Contact: Website

Re: GPIO via bash??

Fri Oct 26, 2012 2:04 pm

redhawk wrote:Thanks, I just managed to toggle my GPIO pin via bash with the minimum amount of effort without the need of a compiler. :)

I guess if I wanted to implement this in Free Pascal all I need to do is treat the GPIO pins as if I was to read / write files or am I wrong??

Richard S.

Yes. That is all that the echo > bash command is doing.

Or, if you can call a C library from Free Pascal, then you could use Gordon's WiringPi API.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com

Killerspec
Posts: 31
Joined: Thu Sep 06, 2012 10:41 pm

Re: GPIO via bash??

Thu Nov 22, 2012 5:39 pm

Hi

I am a complete newbie to Pi and programming but I do love electronics as a hobby. I am looking at taking my hobby to the next level and automate my projects. I am wondering if there is a guide out there to help a beginner like myself our a book that I can buy that deals with the programming side.

I have my Pi and I am using a Adafruit proto board to help me work cleaner.

Please help

Matthew

Return to “Interfacing (DSI, CSI, I2C, etc.)”