Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

Hour 23. Creating Basic Pi/Python Projects


What You’ll Learn in This Hour:
How to display HD images via Python
How to use Python to play music
How to create a special presentation

In this hour, you will learn how to create some basic projects on your Raspberry Pi using Python. You
will learn how to make your very own high-definition image presentation, how to use Python to play a
list of music on your Raspberry Pi, and how to create a special presentation using Python.


Thinking About Basic Pi/Python Projects


The sky is the limit when it comes to creating projects using your Raspberry Pi and Python! The
projects in this hour and the next will help you improve and solidify your Python script-writing skills.
Also, you will learn to take advantage of some of the nice features on your Raspberry Pi. And,
hopefully, by working on these projects, you will be inspired for additional ventures!


This hour covers a few simple projects. You’ll create something useful, without spending any
additional money. You already have all you need for this hour’s basic projects: a Raspberry Pi and
Python.


Displaying HD Images via Python


One of the Raspberry Pi’s greatest features is its small size. Carrying around a Pi is even easier than
carrying a tablet computer. Another great feature is the Raspberry Pi’s HDMI port. The HDMI port
allows you to display high-definition images from your Pi.


These two features together make the Raspberry Pi a perfect platform for many uses. You can take
your Pi over to a friend’s house, hook it up to his or her television, and show your vacation pictures.
For a business person, the small size of a Pi makes it ideal for travel and making business
presentations. For a student, imagine how impressed your teacher will be to not only see your
presentation from the Pi, but to learn that you wrote the script that runs it.


Understanding High Definition


There can be a lot of confusion concerning HD. Therefore, before you begin to build the scripts this
hour, you need to learn about—or review—what is meant by a high-definition (HD) image.


Other terms for the dimensions of an image are canvas, size, and resolution. This alone can cause
confusion! Basically, the dimensions of a picture are the image’s width times its height. It is measured
in pixels and is often written in the format width × height. For example, a picture may have the
dimensions 1280×720 pixels.


The dimensions of a picture determine whether it is HD. Larger dimension numbers mean a higher
resolution. A higher resolution provides a clearer picture. Thus, if you have a new beautiful product
to sell your client, an HD picture of it will be worthwhile. Table 23.1 shows the resolutions for each
current definition.

Free download pdf