Tag Archives: Python

Programming Languages and Raspberry Pi

There are two programming languages that are popular for use with the Raspberry Pi computer.  The first is Scratch which is a visual programming language.  The second is Python which has a more traditional approach, with text-based language statements, and use of a text editor interface for program development.

Last year, the Rutland Tech Club hosted two Scratch programming events.  Scratch is a visual programming tool developed by MIT.  The programming language constructs resemble “Lego” blocks which can be snapped together on the computer screen to build programs.

On the Raspberry Pi computer, the Raspian Linux operating system it comes with it’s own custom version of Scratch.  This version of Scratch allows access to GPIO connections on the Raspberry Pi, which are the general purpose I/O or input/output connections.  That means you can access external input sensors and output devices which can be connected to the Raspberry Pi, via the GPIO connectors.  For example, you can instruct Scratch to read in a sensor input (i.e. motion sensor, temperature sensor, etc.) or send output command to output device (i.e. camera, LED lights, etc).

Python uses the more traditional form of programming, using text commands and statements, where the programmer must input the proper program language syntax in order to instruct the Raspberry Pi what to do.  Python is a popular computer language, which has some interesting syntax features.  Unlike other computer languages, the “if” statement (conditional, if – then – else), does not use curly braces “{” and “}” to delineate the statements within an if code block or else code block.  Instead, Python uses consistent code “indenting”.  This can make for a more readable program.  In other words, program whitespace or indenting is critical in Python, whereas in other languages, proper use of whitespace is not critical (although highly recommended for readability).

Just as in Scratch programming, you can use Python to access GPIO connections to input sensors and output devices.  The Python approach is text-based programming instead of Scratch’s visual programming method, but the same types of things can be done in both languages.

The Codecademy.com website is a good place to begin to learn Python.  The tutorials are grouped into units and also include some problem solving exercises to allow you apply what you just learned.

Whatever types of projects you want to do on your Raspberry Pi, having some knowledge of Scratch or Python programming is very helpful.