Fast delivery
Discount conditions for companies
Up to 10% discount for pupils, students and educational institutions
Europe wide shipping for 4,90€

Getting Started with the Raspberry Pi - Part 3: Programming

In principle, you can also install the Arduino IDE on the Raspberry Pi or program in different programming languages with the pre-installed program Geany, a very functional editor, but the Raspberry Pi takes its name from the Python programming language; originally it was only planned as a Python interpreter. So: Who says programming the Raspberry Pi, usually means the very widely used and easy to learn language Python.

In the last few years, the program Thonny has established itself as an Integrated Development Environment (IDE) for Python programs.

 Thonny - Development environment for the Raspberry Pi

One differentiates basically the editor in the upper part of the window, here the programs are written, and the Shell in the lower part, here the programs with possible inputs and outputs run. One can enter however also in the Shell directly short commands.

Advanced programmers should click on "Switch to regular mode" in the upper right corner of the screen to get the menu bar displayed as well.

 Thonny - Development Environment for the Raspberry Pi - Advanced Mode

If you want to learn the programming language autodidactically, you can do this with the help of a lot of books. At this point the method "learning by doing" is recommended, i.e. simply copy the program examples. Mostly the program code is self-explanatory. That is the beauty of Python.

In order to avoid unnecessary frustration, a few rules should be mentioned at this point, which are primarily aimed at those switching from Arduino C/C++:

The variable type does not have to be declared, in contrast to C/C++. Python recognizes the type the first time it is used. For example, if you type ("abc") in the shell, you get <class 'str'> as output; so the type string is recognized because of the apostrophes.

The command line is not terminated with a semicolon. Instead, Python requires careful attention to indentation. So: every command always starts at the first position of the paragraph.

Indentations (usually tab=four spaces) are done (mostly automatically) for branches, loops or self-defined functions, if necessary several times.

Program and variable names always start with a letter or the underscore _. After that, numbers can also be used. The underscore is the only special character allowed and is mostly used for special purposes.

As said before: More explanations about Python with the program examples.

Topics: #raspberry, #wissen
Please enter the string in the text field below.

The fields marked with * are required.