Sunday, March 6, 2016

Raspberry Pi GPIO, Python, & Push Button Circuit - Simple Print to Shell Commands

After successfully getting a better handle on how to rework Python code on the Raspberry Pi, I decided to do another modification of a totally different GPIO project that utilizes two push buttons to send print commands to the Python Shell. Although I'm fairly sure Python already comes bundled with Raspbian OS, this tutorial helped me get started with understanding how to install Python and upgrades on the RPi.

Using the RPi terminal to install Python 2.7.9

I then combined information from two different GPIO tutorials from electrosome.com and make.com on having the Python shell print out confirmations when pressed. The make.com tutorial had good information, but the code was not properly formatted with the necessary indentation, so I used the electrosome.com code (which was properly formatted) as a guide. I was  then able to load the same Python script with 2 different strategies: using Nano or using Python IDLE 2.7.9 to have the push buttons send print commands to the Python Shell window.

code in GNU nano


HowToGeek.com had a great intro to GNU nano that helped me understand the key commands. By the way, ^ for their command key menu stands for the Ctrl key.