GPIO using Python3

Hi all,

I’m new the BBB and have taken one college course in programming. Intro to programming using Python3. I wanted to program the BBB using Python3, but ran into the issue that Adafruit’s module was Python 2.7. I struggled with this for a while, until I came across a post by Joran B. on another website. He provided a bit of code to simply use the GPIO directly in Python3. I’m sure it’s obvious to the advanced users, but I found his post very useful. His code didn’t work for me at first, but I was able to add a few lines and get it working. I’ve attached the file. Now I just simply import it (add “from gpio import SimpleGPIO” to the beginning of my python code) and it works great. I learned a ton about how to access and use the GPIO by going through the code in his post and getting it to work. Any other newbies wanted to do something similar, I’ve attached the file for reference as well as an example of where I used it during my test. Please note, I haven’t tested the xxx.read() method. Just turned on and off an LED so far.

gpio.py (826 Bytes)

test.py (75 Bytes)

OK so let me just say right off that I am not a python anything. I can read python, and I read bogs post etc ( news ) about python, and everything I’ve read says stick with 2.7. The reason behind this is simply maintainability. It can be really really hard to maintain code using 3.0 versus 2.7 specific libraries.

Which may / may not matter if you’re only maintaining a small code base. . .