How to use GPIO numbers instead of internal IO numbers
Posted: Sun Jan 04, 2015 3:49 am
Hiya
Thought I'd just break out a line from a script I developed recently to allow the use of GPIO numbers as reference rather than the internal IO codes. It saves having to look-up the reference and also reduces the chances for simple mistakes. This array is good for the new mapping, after build 20141219.
After this line you can refer to pins like this:
Hope this is a handy line!
Thought I'd just break out a line from a script I developed recently to allow the use of GPIO numbers as reference rather than the internal IO codes. It saves having to look-up the reference and also reduces the chances for simple mistakes. This array is good for the new mapping, after build 20141219.
Code: Select all
gpio= {[0]=3,[2]=4,[4]=2,[5]=1,[12]=6,[13]=7,[14]=5,[15]=8,[16]=0}
After this line you can refer to pins like this:
Code: Select all
sda=gpio[12] -- connect sda to pin GPIO12
led=gpio[14] -- connect led to pin GPIO14
Hope this is a handy line!