A new tutorial to help beginners control hardware with Python.
"Hey, I heard that the Raspberry Pi will teach you to program!"
"I bought a Raspberry Pi because it's cheap...now what do I do with it?"
These are the two most common phrases I hear when people are trying to figure out what to do with the Raspberry Pi. Certainly, the Pi is a great piece of inexpensive hardware that functions as a complete Linux (or other operating system) computer.
In response to the "Raspberry Pi will teach you to program" comment, I usually tell people, "Not any more than your current computer." The Pi can't magically upload programming knowledge to your brain (yet).
That being said, the Raspberry Pi can be a fun learning environment for individuals and schools thanks to several factors:
Python has been gaining in popularity as a beginner-friendly-yet-still-powerful programming language over the past few years (according to several indexes like TIOBE and PYPL). Many schools are switching to Python to teach students as their first language. It's approachable due to its script-like nature, but it can be used to teach more advanced concepts like polymorphism.
As a result, the Raspberry Pi can be a perfect platform for learning Python. There are plenty of books, websites and videos out there that can help you learn Python. However, we find there is something special about controlling a piece of hardware (spinning a motor, lighting an LED, taking a temperature reading) through programming. So, we've put together a guide to help you get started controlling hardware with Python on the Raspberry Pi:
The raspberry-gpio-python module thankfully makes controlling pins super easy. Once you have the basics down (toggling pins, reading pin states, UART, SPI, I2C), you can control a whole suite of hardware, and the fun begins there. Robotics, IoT sensors, home automation projects, etc. become attainable.
What other combination of Python, Raspberry Pi and hardware projects/concepts would you like to see? Let us know in the comments!
 
 
I would like to see how you can interact with raspberry pi from a web based interface, effectively controlling it remotely.
https://xkcd.com/1987/ Anyway the first post is very good, you are one of the few guy that start telling which python version are you using.
Hi Shawn!
As usual, a great blog post. I haven't had time to read through the tutorial in detail, but glancing through it, it looks good.
My one comment is that there's a really big advantage to learning coding with a Raspberry Pi as opposed to an Arduino, and that is that the RPi has access to many debuggers. IM[NS]HO, using a debugger to single-step through a program, especially one with loops, and watch the variables change, is by far the best (and fastest) way to learn about that sort of thing. (My "standard rant" about the Arduino IDE is the absense of any sort of a debugger -- something which appeared in IDEs in the late 1970s, when I'd only been programming for about a decade.)
Another advantage of RPi is that it (normally) runs Linux, and is a great way to learn about this OS. While M$ Windows is "easier" for the raw beginner with computers (think "elderly aunt"), once you get beyond the stage of using (or I would claim "being abused by") the canned programming (e.g., "social[sic] media", web surfing, e-mail, Skype), Linux can be much more friendly. BTW, I've been using Unix and Unix-like systems since the mid-70s, and been abused by Window$ since W 3.1.
I'd like to see some articles on C programming on the Raspberry Pi. Python is all well and good, but to get more performance, C is hard to beat. Not only that, but introducing people to working with a compiled language like C opens up new areas of interest too.
We do have some C/C++ examples for the Pi. Check out the Raspberry Pi gPIo and Raspberry Pi SPI and I2C tutorials.