13

What Next

The Raspberry Pi is a phenomenally flexible device that you can use in all sorts of situations—as a desktop computer replacement, a media center, or an embedded computer to be used as a control system.

This chapter provides some pointers for different ways of using your Raspberry Pi and details some resources available to you for programming the Raspberry Pi and making use of it in interesting ways around the home.

Linux Resources

The Raspberry Pi is, of course, one of many computers that runs Linux. You will find useful information in most books on Linux; in particular, look for books that relate to the distribution you are using, which for Raspberry Pi OS will be Debian.

Aside from the File Manager and applications that require further explanation, you’ll want to know more about using the Terminal and configuring Linux. A useful book in this area is The Linux Command Line: A Complete Introduction, by William E. Shotts, Jr. Many good resources for learning more about Linux can be found on the Internet, so let your search engine be your friend.

Python Resources

Python is not specific to the Raspberry Pi, and you can find many books and Internet resources devoted to it. For a gentle introduction to Python, you might want to pick up Python: Visual QuickStart Guide, by Toby Donaldson. It’s similar to this book in style, but provides a different perspective. Also, it’s written in a friendly, reassuring manner. If you want something a bit more meaty, but still essentially a beginner’s text, consider Python Programming: An Introduction to Computer Science, by John Zelle.

When it comes to learning more about pygame, you’ll find Beginning Game Development with Python and Pygame, by Will McGugan, to be quite helpful.

Finally, here are some good web resources for Python you’ll probably want to add to your browser’s favorites list:

Images   http://docs.python.org/py3k/  The official Python site, complete with useful tutorials and reference material.

Images   https://lawsie.github.io/guizero  The official documentation for guizero.

Images   https://gpiozero.readthedocs.io  The documentation for gpiozero.

Images   www.pygame.org  The official pygame site. It contains news, tutorials, reference material, and sample code.

Raspberry Pi Resources

The official website of the Raspberry Pi Foundation is www.raspberrypi.org. This website contains a wealth of useful information, and it’s the place to find announcements relating to happenings in the world of Raspberry Pi.

The forums are particularly useful when you are looking for the answer to some knotty problem. You can search the forum for information from others who have already tried to do what you are trying to do, you can post questions, or you can just show off what you’ve done to the community. When you’re looking to update your Raspberry Pi distribution image, this is probably the best place to turn. The downloads page lists the distributions currently in vogue.

The Raspberry Pi even has its own online magazine, wittily named The MagPi. This is a free PDF download (www.themagpi.com) and contains a good mixture of features and “how-to” articles that will inspire you to do great things with your Pi.

For more information about the hardware side of using the Raspberry Pi, the following links are useful:

Images   http://elinux.org/RPi_VerifiedPeripherals  A list of peripherals verified as working with the Raspberry Pi.

Images   http://elinux.org/RPi_Low-level_peripherals  A list of peripherals for interfacing with the GPIO connector.

If you want to go into more depth about the Raspberry Pi, especially connecting it to electronics, then you can refer to my book Raspberry Pi Cookbook which contains recipes for pretty much anything you might want to do with your Raspberry Pi.

If you are interested in buying hardware add-ons and components for your Raspberry Pi, Adafruit has a whole section devoted to the Raspberry Pi. SparkFun also sells Raspberry Pi add-on boards and modules. In the United Kingdom, CPC, Pimoroni, and Kitronik all sell interesting add-ons for the Raspberry Pi.

Programming Languages

In this book, we have looked exclusively at programming the Raspberry Pi in Python, and with some justification: Python is a popular language that provides a good compromise between ease of use and power. However, Python is by no means the only choice when it comes to programming the Raspberry Pi. The Raspberry Pi OS distribution includes several other languages.

Scratch

Scratch is a visual programming language developed by MIT. It has become popular in education circles as a way of encouraging youngsters to learn programming. Scratch includes its own development environment, like IDLE for Python, but programming is carried out by dragging and dropping programming structures rather than simply typing text.

Figure 13-1 shows a section of one of the sample programs provided with Scratch for the game Pong, where a ball is bounced on a paddle.

Images

Figure 13-1 Editing a program in Scratch.

Simon Walters has developed a GPIO library so that you can use Scratch to control GPIO pins.

C

The C programming language is the language used to implement Linux, and the GNU C compiler is included as part of the Raspbian Wheezy distribution. To try out a little “Hello World”’ type of program in C, use Mu to create a file with the following contents:

Images

Save the file, giving it the name hello.c. Then, from the same directory as that file, type the following command in the terminal:

gcc hello.c -o hello

This will run the C compiler (gcc), converting hello.c into an executable program called just hello. You can run it from the command line by typing the following:

./hello

The Mu editor window and command line are shown in Figure 13-2, where you can also see the output produced. Notice that the characters create blank lines around the message.

Images

Figure 13-2 Compiling a C program.

Other Languages

You will also find a couple of IDE options for Java programming on the Start menu. So, if you want to learn Java (NOT to be confused with JavaScript), you can do so on your Raspberry Pi. The newest Raspberry Pi models are perfectly capable of running a web server stack, which includes a database and web server. The options for this change frequently with the latest fashion in web development.

Applications and Projects

Any new piece of technology such as the Raspberry Pi is bound to attract a community of innovative enthusiasts determined to find interesting uses for the Raspberry Pi. At the time of writing, a few interesting projects were in progress, as detailed next.

Media Center (Kodi)

LibreELEC is a distribution for the Raspberry Pi based on the Kodi software that turns it into a media center you can use to play movies and audio stored on USB media attached to the Pi, or you can stream audio and video from other devices such as iPads that are connected to your home network. When you use NOOBS to set up your Raspberry Pi (see Chapter 1), installing LibreELEC is an option on the NOOBS screen.

With the low price of the Raspberry Pi, it seems likely that a lot of them will find their way into little boxes next to the TV—especially now that many TVs have a USB port that can supply the Pi with power.

You can find out more about LibreELEC at https://libreelec.tv/.

Home Automation

Many small-scale projects are in progress that use the Raspberry Pi for home automation, or domotics as it is also known. The ease with which sensors and actuators can be attached to it, either directly or via an Arduino, make the Pi eminently suitable as a control center.

Most approaches have the Raspberry Pi hosting a web server on the local network so that a browser anywhere on the network can be used to control various functions in the home, such as turning lights on and off or controlling the thermostat.

Technologies to look for here are MQTT (mosquitto) and NodeRED.

Summary

The Raspberry Pi is a very flexible and low-cost device that will assuredly find many ways of being useful to us. Even as just a simple home computer for web browsing on the TV, it is perfectly adequate (and much cheaper than most other methods). You’ll probably find yourself buying more Raspberry Pi units as you start to embed them in projects around your home.

Finally, don’t forget to make use of this book’s website (www.raspberrypibook.com), where you can find software downloads, ways of contacting the author, as well as errata for the book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.130.218