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.
-
- Posts: 1562
- Joined: Sun Mar 04, 2012 12:49 am
Re: GPIO via bash??
yes you can - I'll look it up and get back to you....
Re: GPIO via bash??
Examples for various languages are given here http://elinux.org/Rpi_Low-level_peripherals
Re: GPIO via bash??
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.

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.
- gordon@drogon.net
- Posts: 2023
- Joined: Tue Feb 07, 2012 2:14 pm
- Location: Devon, UK
- Contact: Website Twitter
Re: GPIO via bash??
Absolutely!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.
first, get my wiringPi library:
Code: Select all
cd
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
Code: Select all
gpio mode 0 out
gpio write 0 1
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
-Gordon
--
Gordons projects: https://projects.drogon.net/
Gordons projects: https://projects.drogon.net/
- tedhale
- Posts: 114
- Joined: Thu Sep 20, 2012 4:52 pm
- Location: Williamsburg, VA, USA
- Contact: Website
Re: GPIO via bash??
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
http://raspberrypihobbyist.blogspot.com
-
- Posts: 31
- Joined: Thu Sep 06, 2012 10:41 pm
Re: GPIO via bash??
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
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