In 2012 the Raspberry Pi Foundation released the first Raspberry Pi board. The foundation designed the device as an affordable computer that would serve as an accessible platform for teaching programming. Ever since, the Raspberry Pi has gained a lot of popularity and people everywhere use it for education, prototyping and even as part of industrial systems.
Although the Raspberry Pi is similar to a computer having reduced capabilities, it also has certain characteristics that make it stand out. One of the board’s main advantages that people make use of is the pins set that it exposes. The pins can be easily connected to simple peripherals, allowing people to build applications such as smart appliances or other IoT solutions.
When it comes to building a Raspberry Pi application, one of the first questions that come to one’s mind is what programming language to use and the simple answer would be “it depends on what you want to program”. Indeed, depending on the applications that you want to build, there are several programming languages to choose from.
Further on, we will describe some of the 5 most common approaches when it comes to programming the raspberry pi.
Python is a programming language that is extensively used in education. As the Raspberry Pi was designed for educational purposes, it is of no surprise that Python is one of the most popular choices as a programming language. What is more, the Raspberry Pi Foundation promotes Python as the main programming language for the Raspberry Pi. One of the main advantages of Python is that it emphasizes indentation, which gets students accustomed to writing clear code. Another important advantage of Python is the result of its extensive use: a large number of available libraries.
For programming the Raspberry Pi, we consider Python is a good choice for building educational applications that control some pins, retrieve data from a web service or include the Pygame module to build some simple games. In addition, we recommend Python for prototyping purposes, in building applications such as smart home systems, smart plants or others. This is because Python enables fast programming and with a wide array of libraries at hand, controlling the Raspberry Pi pins is not a difficult task.
For pin control, we recommend you include the wiringpi library. It is a Python library specially designed to run on the Raspberry Pi and it allows GPIO control using Arduino-like functions. This makes it easy to turn on LEDs and read buttons.
Similarly to Python, Node.js is a popular programming language and a plethora of libraries and frameworks have been developed around it. The most important framework to be taken into account is express. Express is the standard framework for building web server using Node.js. It offers a simple API that allows developers to easily create a basic backend for a web application.
Since the Raspberry Pi has become more and more popular, the number of people willing to build their own connected system around it has increased to such an extent that even non-technical persons have acquired such a device and are tinkering with it. As a result, one of the main options that we recommend for programming the Raspberry Pi is visual languages, with the two main choices being Scratch and Blocky.
Both Scratch and Blockly are programming languages based on visual blocks that generate a Python or other programming language application when interconnected. While Scratch was developed by MIT together with a web interface where children can build stories and games by using the visual elements, Blockly is a Google’s project whose main purpose is to be integrated into third-party solutions. However, both are open-source projects that can be extended and integrated into other systems. Therefore, both can be used to program the Raspberry Pi.
For programming the Raspberry Pi using Scratch, you need to connect the device to a keyboard, a mouse and a display and install the environment. Then you can create the applications directly on the Raspberry Pi.
For Blockly, you can use Wyliodrin STUDIO as a programming environment for the Raspberry Pi. For this, you need to download the IDE on a computer that is connected to the same network as the Raspberry Pi. Then you will build the applications on your computer and deploy them on the device to run. In this case, you only need to connect the Raspberry Pi to the network, no display or keyboard required.