desmondttm123
Posts: 103
Joined: Tue May 07, 2013 6:13 am

simplify wiringpi

Thu Jun 27, 2013 4:20 am

hello guys! i recently installed wiring pi and to test it, i decided to turn on a simple LED. however i find it a bit tedious to turn on a simple LED. i have to type in gpio write 1 1 and so on. i was wondering if there are ways to simplify these commands? or maybe alternative ways to activate? such as via phone? thanks

User avatar
rpdom
Posts: 14985
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: simplify wiringpi

Thu Jun 27, 2013 4:55 am

Perhaps you could write a script called "led" or something and use "led 1 on" and "led 1 off"?

User avatar
drewibbo
Posts: 41
Joined: Tue Feb 26, 2013 11:54 am
Location: Worthing, UK
Contact: Website

Re: simplify wiringpi

Thu Jun 27, 2013 6:53 am

To elaborate on rpdom's post. You can make a script and include the following at the beginning:

Code: Select all

redon= "gpio write 1 1"
redoff= "gpio write 1 0"
greenon= "gpio write 2 1"
greenoff= "gpio write 2 0"
You can then use them in your script to quickly turn them on and off:

Code: Select all

$redon
$greenon
sleep 1
$redoff
$greenoff
It doesn't save much time coding but is an easy way to recognise it in a long script. :D

Andy
Pi Pi Pi...

Return to “General discussion”