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!