Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Raspberry Pi By Example
Raspberry Pi By Example

Raspberry Pi By Example: Start building amazing projects with the Raspberry Pi right out of the box

eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi By Example

Chapter 1. Introduction to Raspberry Pi and Python

One can learn about topics in computer science in an easy way with the Raspberry Pi and Python. The Raspberry Pi family of single-board computers uses Python as the preferred development language. Using Raspberry Pi and Python to learn programming and computer science-related concepts is one of the best ways to start your journey in this amazing world of computers that is full of creative possibilities. We will explore these possibilities in this book.

We will commence our journey in this chapter by getting ourselves familiar with the following topics:

  • Single-board computers
  • Raspberry Pi
  • Raspbian
  • Setting up Raspberry Pi
  • Basics of Python
  • Turtle programming with Python

Single-board computers

A single-board computer system is a complete computer on a single circuit board. The board includes a processor(s), RAM, input/output (I/O), and networking ports for interfacing devices. Unlike traditional computer systems, a single-board computer is not modular and its hardware cannot be upgraded as it is integrated on the board itself. Single-board computers are used as low-cost computers in academia, research, and embedded systems. The use of single-board computers in embedded systems is quite prevalent and many individuals and organizations have developed and released fully functional products based on single-board computers.

The Microcomputer Trainer MMD-1 designed by John Titus in 1976 is the first true single-board microcomputer that was based on the Intel C8080A. It was called dyna -micro in the prototyping phase, and the production units were called MMD-1 (short for Mini Micro Designer 1).

Popular single-board computers available in the market include but are not limited to Raspberry Pi, Banana Pro, BeagleBone Black, and Cubieboard. The following images are of the front view of BeagleBone Black, Banana Pro, and Cubieboard 4, respectively:

Single-board computers

Raspberry Pi

The Raspberry Pi is a series of low-cost, palm-sized single-board computers developed by Raspberry Pi Foundation in the UK. The intention behind the creation of the Raspberry Pi is to promote the teaching of basic computer skills in schools, which it serves very well. Raspberry Pi has expanded its footprint well beyond its intended purpose by penetrating the embedded systems market and computer science research.

Note

This is the home page of Raspberry Pi Foundation: http://www.raspberrypi.org.

The Raspberry Pi is manufactured with licensed agreements with Newark element14, RS Components, Allied Electronics, and Egoman. These companies manufacture and sell the Raspberry Pi. The hardware is the same across all manufacturers.

The following table displays the URLs of the manufacturers' websites, where you can shop for Pi and related items online:

Manufacturer

Website

Newark element14

http://www.newark.com

RS Components

http://uk.rs-online.com

Egoman

http://www.egoman.com.cn

Allied Electronics

http://www.alliedelec.com

You can also shop for Pi and the other third-party add-ons at the following links:

Raspberry Pi models

The following are, at the time of writing this, the major models of Raspberry Pi:

  • Model A (not in production; discontinued in favor of the production of later and upgraded models)
  • Model A+ (currently in production and available for purchase)
  • Model B (available for purchase but not in production)
  • Model B+ (currently in production and available for purchase)
  • Raspberry Pi 2 Model B (currently in production and available for purchase)

Note

Check out the Product page of Raspberry Pi at http://www.raspberrypi.org/products/.

Additionally, Raspberry Pi is also available in a more flexible form factor intended for industrial and embedded applications. It is known as Compute Module. A Compute Module prototyping kit is also made available by the foundation.

Note

Check out the following URLs for the Compute Module and Compute Module development kit, respectively:

http://www.raspberrypi.org/products/compute-module/

http://www.raspberrypi.org/products/compute-module-development-kit/

The following table compares the currently available models of Pi:

Raspberry Pi models

The following image shows the top view of the Raspberry Pi Model B front:

Raspberry Pi models

The following image shows the top view of the flip side of Raspberry Pi Model B:

Raspberry Pi models

The following image shows the top view of the Raspberry Pi Model B+ front:

Raspberry Pi models

The following image shows the top view of the flip side of Raspberry Pi Model B+:

Raspberry Pi models

The following image shows the top view of the Raspberry Pi 2 Model B front. The location of the connectors and important ICs (integrated circuits) on the board is not different from Pi B+:

Raspberry Pi models

We will be using Raspberry Pi 2 Model B throughout this book. However, all the applications and programs in this book will work on all the models of Pi.

Operating systems

The Raspberry Pi primarily uses Unix-like Linux-kernel-based operating systems, such as variants of Debian and Fedora.

Raspberry Pi Models A, A+, B, and B+ are based on the ARM11 family chip, which runs on the ARMv6 instruction set. The ARMv6 instruction set does not support Ubuntu and Windows.

However, the recently launched Raspberry Pi 2 is based on ARM Cortex A7, which is capable of running Windows 10 and Ubuntu (Snappy Core). The following operating systems are officially supported by all the models of Raspberry Pi and are available for download at the download page:

  • Raspbian: We will be using this with Raspberry Pi throughout the book
  • OpenELEC
  • Pidora (Fedora Remix)
  • RASPBMC
  • RISC OS

Note

Windows 10 and Ubuntu are only supported by the recently launched Pi 2.

Raspbian

Raspbian is an unofficial variant of Debian armhf (ARM Hard Float) compiled for hard float code that will run on Raspberry Pi computers. It is a free operating system based on Debian optimized for the Raspberry Pi hardware.

Note

To know more about Raspbian, visit http://www.raspbian.org/.

Setting up the Raspberry Pi

We need the following hardware to set up a Pi.

  • Raspberry Pi 2 Model B (hereafter, this will be referred only as Pi).
  • Power Supply: A micro USB power supply.

    Considering that we are going for slightly power-intensive usage of our Pi (such as connecting Pi Camera, webcam, and third-party sensors for Pi), a 5V 2A power supply is recommended. The micro USB pin is shown in the following image:

    Setting up the Raspberry Pi

    Note

    You can find a similar one online at http://www.adafruit.com/product/1995.

  • A standard USB keyboard
  • A MicroSD card and a MicroSD to SD card converter

    We need a minimum 4 GB Micro SD card.

  • A USB mouse
  • A monitor

    You can use either an HDMI monitor or a standard VGA monitor.

  • A monitor connection cable and converter

    If you are using HDMI monitor, then an HDMI cable will be sufficient. If you are using a VGA monitor, then you need to use an HDMI to VGA converter with a VGA cable. Some special changes need to be made to the /boot/config.txt file if you're using a VGA monitor, which will be explained in the next section.

    Setting up the Raspberry Pi

    Note

    You can find a similar one online at https://www.adafruit.com/products/1151.

  • A Windows, Linux, or Mac OS computer with a MicroSD card reader and an Internet connection

Preparing MicroSD card manually

This is the original way to install an OS into a MicroSD card, and many users, including me, still prefer it. It allows the SD card to be prepared manually before it is used and it allows easier access to configuration files such as /boot/config.txt, which we might have to modify in a few cases before booting up. The default Raspbian image consists of only two partitions, BOOT and SYSTEM, which will fit into a 2 GB card. However, I recommend that you use a minimum 4 GB card to be on safe side. Choosing an 8 GB card will be adequate for most of the applications we are going to develop in this book.

The following are the instructions for Windows users:

  1. Download the Win32DiskImager installer, which is available at http://sourceforge.net/projects/win32diskimager/files/latest/download and then install it.
  2. Download the installable version of WinZip, which is available at http://www.winzip.com/prod_down.html, and install it.
  3. Go to http://www.raspberrypi.org/downloads and download the latest image of Raspbian. It will be a compressed file in the ZIP format and will need to be extracted.
  4. Extract the ZIP file using WinZip. The extracted file will be in the .img format.
  5. Insert the microSD card into the card reader and plug the card reader into the computer. Many computers nowadays have an inbuilt SD card reader. In this case, you will need to insert the microSD card into the microSD to SD card converter and insert it into the computer's inbuilt SD card reader. MicroSD to SD card converters usually come bundled with microSD cards in the same package. If that's not the case, then you will have to procure it separately.
  6. Run Win32DiskImager.exe and write the image onto the SD card:
    Preparing MicroSD card manually

    You might receive the following message if the card reader's write protection is on:

    Preparing MicroSD card manually
  7. Toggle the write protection notch and try again. You will see the following message:
    Preparing MicroSD card manually
  8. Click on Yes and it will start writing the image file to the microSD card:
    Preparing MicroSD card manually
  9. Once the image is successfully written, it will display the following message:
    Preparing MicroSD card manually

Note

If you are using Linux, then you can find the instructions at https://www.raspberrypi.org/documentation/installation/installing-images/linux.md.

If you are using Mac OS, then you can find the instructions at https://www.raspberrypi.org/documentation/installation/installing-images/mac.md.

If you have an HDMI monitor, then skip this step. This additional step is required only if you are planning to use a VGA monitor in place of an HDMI monitor.

Browse the microSD card on the computer. Locate and open config.txt. We have to edit the file in order to enable proper display on the VGA monitor.

By default, the commented options (which have # at the beginning) are disabled. We are enabling this option by uncommenting this line, that is, by removing # from the beginning of the commented line. This is what you need to do:

  1. Change #disable_overscan=1 to disable_overscan=1.
  2. Change #hdmi_force_hotplug=1 to hdmi_force_hotplug=1.
  3. Change #hdmi_group=1 to hdmi_group=2.
  4. Change #hdmi_mode=1 to hdmi_mode=16.
  5. Change #hdmi_drive=2 to hdmi_drive=2.
  6. Change #config_hdmi_boost=4 to config_hdmi_boost=4.
  7. Save the file.

Booting up our Pi for the first time

Let's boot up our Pi for the first time with the microSD card:

  1. Insert the microSD card into the microSD card slot of the Pi.
  2. Connect the Pi to the HDMI monitor. If you are connecting the VGA monitor, connect it using the HDMI to VGA converter.
  3. Connect the USB mouse and the USB keyboard.
  4. Connect the Pi to a power supply using the micro USB power cable. Make sure the power is switched off at this point.
  5. Check all the connections once and then switch on the power supply of the Pi.

At this stage, our Pi will start booting up. You will see a green light on the Pi board blinking. This means that it's working! Now, there are few more things we need to do before we can really start using our Pi. Once it boots up, it will show the desktop as follows:

Booting up our Pi for the first time

Once the desktop is visible, go to Menu | Accessories | lxterminal. Then, type sudo raspi-config. A text-based menu, such as the following, will appear:

Booting up our Pi for the first time

Perform the following steps. We need to use arrow keys and the Enter key to select options in the text-based menu. Press Enter to select a menu item. Also, we can use the Tab key to directly go to the Select and Finish buttons:

  1. Select Expand Filesystem.
  2. In Boot Options, select B4 Desktop Autologin, as shown in the following screenshot:
    Booting up our Pi for the first time

    Note

    The default username is pi and the password is raspberry. We need it when we don't choose any of the preceding autologin options. We can change this password from the second option in the raspi-config menu.

    We can also choose to boot to the console by selecting any of the first two options in the preceding menu. The default shell of Raspbian is Bash. We can confirm it by typing the following command:

    echo $SHELL
    

    We can always go to the graphical desktop from the Command Prompt by typing the startx command in the console.

  3. Go to Internationalisation Options | Change Timezone.
  4. Go to Internationalisation Options | Change Keyboard Layout | Change it to US (the default is UK).
    Booting up our Pi for the first time
  5. Select Enable Camera.
  6. Select Advanced Options.
  7. Under this option, select Memory Split and enter 64MB for GPU.

This option decides how much RAM is used by the GPU (Graphics Processor Unit). The more RAM is allocated to the GPU, the more intensive graphics processing can be done. 64 MB is a good value for most graphics purposes.

Once all these options are modified, select Finish. This will prompt for a reboot of the Pi. Choose Yes and let it reboot. Once rebooted, it will automatically take us to the Raspbian Desktop again.

You can always invoke the raspi-config tool from Command Prompt with the following command and change the settings:

sudo raspi-config

Shutting down and rebooting Pi safely

In the Raspbian menu, there are options to shut down and reboot the Pi.

If we click on the following Menu button on the desktop, it will display multiple options:

Shutting down and rebooting Pi safely

The following image shows the last option:

Shutting down and rebooting Pi safely

If we click on the preceding option, the following window will appear:

Shutting down and rebooting Pi safely

Also, from Command Prompt LXTerminal, we can shut down Pi safely by issuing the following command:

sudo shutdown –h now

An alternative command for this is as follows:

sudo halt

You can reboot Pi with the following command:

sudo reboot

Updating the Pi

Now we have a working Pi running on the Raspbian OS. Let's update our Pi. Make sure you have a working wired or wireless Internet connection with reasonable speed for this activity:

  1. Connect your Pi to an Internet modem or router with an Ethernet cable or plug in the Wi-Fi dongle to one of the USB ports.
  2. Run the following command to restart the networking service:
    sudo service networking restart
    
  3. Make sure that your Raspberry Pi is connected to the Internet by typing the following command:
    ping –c4 www.google.com
    
  4. apt (Advanced Package Tool) is the utility used to install and remove software in Debian and its variants. We need to use it to update our Pi software.
  5. Run the following commands in a sequence:
    • sudo apt-get update: This command synchronizes the package list from the source. Indexes of all the packages are refreshed. This command must be issued before we issue the upgrade command.
    • sudo apt-get upgrade: This command will install the newest versions of all the already installed software. Any obsolete packages/utilities are not removed automatically. If any software is in its newest version, then it's left as it is.
    • sudo rpi-update: This command is used to upgrade the firmware. The kernel and firmware are installed as a Debian package, and so they will also get updates. These packages are updated infrequently after extensive testing.
    • sudo reboot: This will reboot the computer.

Getting started with Python

Python is a high-level general-purpose programming language. It supports multiple programming paradigms, such as object-oriented programming, imperative programming, functional programming, procedural programming, aspect-oriented programming, and metaprogramming. It has a dynamic type system, automatic memory management, and a large standard library to carry out various tasks. It emphasizes code readability, and its syntax allows you to carry out tasks in fewer lines of code than other programming languages, such as C or C++.

Python was conceived and implemented by Guido van Rossum at CWI in the Netherlands as a successor to the ABC language, capable of exception handling and interfacing with the Amoeba operating system platform. Van Rossum is Python's principal author, and he continues to have the central role in deciding the direction of Python. He has been endowed with the title benevolent dictator for life (BDFL) by the worldwide Python community.

The core philosophy of the Python programming language is mentioned in this URL: https://www.python.org/dev/peps/pep-0020/; its first few lines are as follows:

"Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts."

Python is the preferred programming language for the Raspberry Pi family of computers. Its interpreter comes preinstalled with Raspbian, and there is no need for any additional installation to get started with code. It is recommended that you have chapter wise directories for the code examples presented in this book, as shown in the following diagram:

Getting started with Python

Let's get started with Python. Open Raspbian's Command Prompt LXTerminal. It is located as a shortcut on the taskbar. Alternately, we can find it by navigating to Menu | Accessories | Terminal. We can start Python in interactive mode by typing python in the prompt and then pressing the Enter key. It will take us to the Python interactive shell, as follows:

Getting started with Python

Now type the following lines and press Enter:

print "Hello World!"

The output will be as follows:

Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hello World!"
Hello World!

Congrats! We have started with Python programming. The interactive mode of Python is suitable for small programs. Press Ctrl + D to exit the interactive shell. For large and code-intensive projects, it's recommended that you use Python in script mode. In this book, we will be using Python in script mode unless specified explicitly. Let's look at how to use Python in script mode.

Create a subdirectory, book, in the /home/pi directory for the code examples in this book. We can do this with mkdir book (by default, we are be in the /home/pi directory). Then, navigate to this recently created directory with the cd book command. We can verify our current directory with the pwd command. It returns the current directory as follows:

pi@raspberrypi ~ $ mkdir book
pi@raspberrypi ~ $ cd book
pi@raspberrypi ~/book $ pwd
/home/pi/book
pi@raspberrypi ~/book $ 

As discussed earlier, we need to keep the code of each chapter in separate directories for better organization. Now, create the chapter01 directory for this chapter in the current book directory using mkdir chapter01. Navigate to this with cd chapter01. At the beginning of each chapter, we are required to create a directory for the chapter under /home/pi/book for the code examples of that chapter.

We will now create a script file for our code and run it.

Use the Nano text editor to create and edit script files. If we type nano prog1.py, then Nano will open prog1.py for editing if it already exists in the current directory; otherwise, it will create a new file with the name prog1.py. You can exit the Nano editor by pressing Ctrl + X.

Note

You can find more information about nano at http://www.nano-editor.org/.

Alternatively, you can use the Leafpad text editor. We can find it by navigating to Menu | Accessories. Or, we can invoke it from Command Prompt with the leafpad prog1.py command.

Finally, you can also use vim, but you will need to install it by running the following command:

sudo apt-get install vim

Note

This is the link for an interactive tutorial on vim: http://www.openvim.com/.

Let's write the same Python code and run it as a script. Write the following code with Nano, Leafpad, or vim, and save it as prog1.py:

print "Hello World!"

To run the preceding program, use the python prog1.py command, and the output will be as follows.

We will run all the other Python programs in this book in the same way.

Let's try some more examples to have more hands-on Python.

The following is the iterative program to calculate the factorial of a given positive integer:

def fact(n):
    num = 1
    while n >= 1:
        num = num * n
        n = n - 1
    return num

print (fact(10))

In the preceding program, def fact(n) is a user-defined function that accepts an argument. The logic used to calculate the factorial of a positive integer follows the definition and the function returns a calculated factorial. The last line of the program calls the factorial function and prints the returned output as follows:

pi@raspberrypi ~/book/chapter01 $ python prog2.py 
3628800

The following is an iterative program for the Fibonacci series:

def fib(n):
    a=0
    b=1
    for i in range(n):
        temp=a
        a=b
        b=temp+b
    return a

for i in range (0,10):
    print (fib(i))

The preceding program prints the first 10 numbers in the Fibonacci series. A more "Pythonic" way of writing the same program, which eliminates the use of a temporary variable, is as follows:

def fib(n):
    a,b = 0,1
    for i in range(n):
        a,b = b,a+b
    return a

for i in range(0,10):
    print (fib(i))

The output of both of the preceding programs is the same and is as follows:

pi@raspberrypi ~/book/chapter01 $ python prog4.py 
0
1
1
2
3
5
8
13
21
34

Turtle programming with Python

Turtle graphics is one of the best ways to learn programming for beginners. Originally, it was part of the Logo programming language, which was primarily used to introduce programming in schools. Python has the turtle module, which is an implementation of the same functionality provided by the original turtle. We can write programs with this module in a procedural as well as object-oriented way.

In Python, when we need to access a module that is not part of the current code, we need to import it. Over the course of the book, we will be importing various modules as and when needed, which will provide us with specific functionalities.

Let's get started with importing the turtle module, as shown here:

import turtle

The following code creates objects for turtle and the screen classes, respectively:

t=turtle.Turtle()
disp=turtle.Screen()

We will use the t.color() function with which we can set the pen and fill color, as follows:

t.color("black","yellow")

We will call the t.begin_fill() and t.end_fill() functions to have our shape filled with a fill color:

t.begin_fill()
t.end_fill()

The code to draw an actual shape we need will be in between these two function calls, as follows:

t.begin_fill()
while 1:
    t.forward(100)
    t.left(190)
    if abs(t.pos())<1:
        break
t.end_fill()
disp.exitonclick()

In the preceding code, t.forward() is used to move the turtle forward a specified distance, and t.left() is used to rotate the turtle left by 190 degrees. t.pos() returns the current coordinates of the turtle.

Finally, we use disp.exitonclick() to close the current output window when we click on the exit button.

Note

At the start, the turtle cursor is at (0,0) and is pointed toward the positive direction of the x axis (facing right).

The output of the program will be a cursor drawing the desired shape progressively, and it helps the programmer understand how the program is actually working. The final output of the preceding program is as follows:

Turtle programming with Python

Note

Detailed documentation for the turtle API can be found at https://docs.python.org/2/library/turtle.html.

Next, we will learn the concept of recursion. In terms of programming, recursion means calling the same block of code within itself. For a procedural and modular style of programming, this stands for calling a function or method within itself. Usually, this is done to break a big problem into similar problems with smaller input sizes and then collect the output of all these smaller problems to derive the output of the big problem. One of the best ways to see recursion at work is to visualize it using a turtle. We will now write a program to draw a fractal tree using recursion.

First, we start by importing the required libraries, as follows:

import turtle
import random

We need the random library for the randint() function, which returns a random integer in the provided range. This is needed to make our generated tree seem different every time. Then, we will define a function to draw a part of the tree recursively:

def fractal_tree(b_len,t):
    if b_len > 5:
        temp=random.randint(1, b_len)
        temp_angle = random.randint(1, 25)
        t.forward(temp)
        t.right(temp_angle)
        fractal_tree(b_len-10,t)
        t.left(2 * temp_angle)
        fractal_tree(b_len-10,t)
        t.right(temp_angle)
        t.backward(temp)

In the preceding program, we are calling the same function twice in order to draw the further branches of the tree. If the b_len parameter is less than or equal to 5, then it will be a leaf (which means that the function will not be called again); else, the recursion will continue. We are randomizing the angle and length of the movement of the turtle while drawing the branches here; otherwise, the tree will be symmetrical, which is very unlikely in real life. The combination of t.forward(), t.backward(), t.left(), and t.right() ensures that at the end of each function call, the turtle cursor is at the same position as where it started.

Finally, we write the routine to call this recursive function:

t=turtle.Turtle()
disp=turtle.Screen()
t.left(90)
t.up()
t.backward(100)
t.down()
t.color("green")
fractal_tree(120,t)
disp.exitonclick()

The cursor does not draw the movements between the t.up() and t.down() function calls. In the preceding code, we are moving the cursor downward by 100 positions so that the tree should fit in the turtle graphics window. When we call fractal_tree() with 120 as the argument, it takes more than 30 minutes due to the high degree of recursion. The output of the preceding program is as follows:

Turtle programming with Python

Summary

In this chapter, we learned about the background of Raspberry Pi and Python. We understood the details of the different models of Pi. We learned how to set up the Raspberry Pi for programming. We also performed some hands-on Python programs. Then, we learned some graphics programming with the turtle library. This got us started with the Pi and the Python programming language, which we will be using throughout the rest of the book.

In the next chapter, we will learn how to play and program minecraft-pi.

Left arrow icon Right arrow icon

Key benefits

  • Explore the vast range of opportunities provided by Raspberry Pi and other hardware components such as a webcam, the Pi camera, and sensors
  • Get hands-on experience with coding, networking, and hardware with the Raspberry Pi platform
  • Learn through ample screenshots that offer a play-by-play account of how to implement Raspberry-Pi-based real-life projects

Description

Want to put your Raspberry Pi through its paces right out of the box? This tutorial guide is designed to get you learning all the tricks of the Raspberry Pi through building complete, hands-on hardware projects. Speed through the basics and then dive right in to development! Discover that you can do almost anything with your Raspberry Pi with a taste of almost everything. Get started with Pi Gaming as you learn how to set up Minecraft, and then program your own game with the help of Pygame. Turn the Pi into your own home security system with complete guidance on setting up a webcam spy camera and OpenCV computer vision for image recognition capabilities. Get to grips with GPIO programming to make a Pi-based glowing LED system, build a complete functioning motion tracker, and more. Finally, get ready to tackle projects that push your Pi to its limits. Construct a complete Internet of Things home automation system with the Raspberry Pi to control your house via Twitter; turn your Pi into a super-computer through linking multiple boards into a cluster and then add in advanced network capabilities for super speedy processing!

Who is this book for?

What's the best way to learn how to use your Raspberry Pi? By example! If you want something exciting to do whilst getting to grips with what your Pi can offer, this is the book for you. With both simple and complex projects, you'll create a wide variety of cool toys and functions with your Raspberry Pi - all with minimal coding experience necessary.

What you will learn

  • Set up your Raspberry Pi and get it ready for some interesting real-life projects
  • Work with images, videos, webcams, and the Pi camera and create amazing time-lapse videos
  • Explore the amazing world of Minecraft Pi
  • Get to know how to use PiGlow for GPIO programming
  • Interface your Pi with Grove Sensors and implement IoT applications
  • Build your own cluster with Raspberry Pi
  • Understand the networking and network programming fundamentals
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 22, 2016
Length: 294 pages
Edition : 1st
Language : English
ISBN-13 : 9781785285066
Vendor :
Raspberry Pi
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Publication date : Apr 22, 2016
Length: 294 pages
Edition : 1st
Language : English
ISBN-13 : 9781785285066
Vendor :
Raspberry Pi
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 104.97
Internet of Things with Python
€41.99
Raspberry Pi By Example
€32.99
Python Programming with Raspberry Pi
€29.99
Total 104.97 Stars icon
Banner background image

Table of Contents

16 Chapters
1. Introduction to Raspberry Pi and Python Chevron down icon Chevron up icon
2. Minecraft Pi Chevron down icon Chevron up icon
3. Building Games with PyGame Chevron down icon Chevron up icon
4. Working with a Webcam and Pi Camera Chevron down icon Chevron up icon
5. Introduction to GPIO Programming Chevron down icon Chevron up icon
6. Creating Animated Movies with Raspberry Pi Chevron down icon Chevron up icon
7. Introduction to Computer Vision Chevron down icon Chevron up icon
8. Creating Your Own Motion Detection and Tracking System Chevron down icon Chevron up icon
9. Grove Sensors and the Raspberry Pi Chevron down icon Chevron up icon
10. Internet of Things with the Raspberry Pi Chevron down icon Chevron up icon
11. Build Your Own Supercomputer with Raspberry Pi Chevron down icon Chevron up icon
12. Advanced Networking with Raspberry Pi Chevron down icon Chevron up icon
13. Setting Up a Web Server on the Raspberry Pi Chevron down icon Chevron up icon
14. Network Programming in Python with the Pi Chevron down icon Chevron up icon
A. Newer Raspberry Pi Models Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(1 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Eugenio M. Sep 28, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Es un libro que recomiendo para los que quieran hacer cosas diferentes con una Raspberry. No es el tipico libro que se basa en los GPIO y las 200 paginas hablan de lo mismo. Este es diferente y me dió la idea de como solucionar un problema de comunicación entre diferentes RPI.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela