Discover fantastic ways to program
the $36 computer that’s taken the world by storm
Raspberry Pi computers were conceived to
inspire programmers to show off their coding talents and earn themselves a place
on the computing degree at Cambridge University. But when word got out about a
$30.5 credit-card-sized computer anyone could buy and write programs for, the
developers were overwhelmed by requests from computer enthusiasts wanting to
know how they could get their own Raspberry Pi. The first edition, the Model B,
launched in February 2012 and cost $43. Since then, its developers have made
good on their promise to offer a $30.5 computer ($36), launching the Model A in
February 2013. More than a million sales later, it’s fair to say programming is
back and the Raspberry Pi a great British success story.
Raspberry
Pi
Setting up your Pi
Download the PDF manual (www.snipca.corn/9250) produced by the
Raspberry Pi Foundation and follow the assembly instructions. The Pi starts up
as soon as you plug it into the mains or attach a battery pack. Don't switch in
on yet though. First, plug in a keyboard, mouse and monitor.
Since there’s only one USB port on the
Raspberry Pi Model A and two USB ports on the Model B, you’ll need a USB hub
for your keyboard and mouse. You’ll need a powered USB hub as the Pi won’t
supply enough current to run them. If you've got a Model A Raspberry Pi, You’ll
also need to plug in a USB Wi-Fi dongle to your powered USB hub.
Install an operating system on your
Raspberry Pi
The Pi’s Raspbian operating system runs
from an SD card. Programs you install will also be stored and run from this
card. You can use SD cards of up to 32GB, but a capacity of 4 or 8GB is plenty.
Raspberry
Pi
You can buy an SD card with the Raspbian
operating system installed on it (www.snipca.com/9314).
However, this Kingston-branded card is only a Class 4 SD card. We recommend
buying a Faster SD card (one with a higher class number) and installing the
free open-source Raspbian OS yourself. You’ll need to format the SD card first,
which you can do on any Windows computer. If your computer doesn't have a
built-in SD card slot you need to attach a USB SD card reader. Formatting will
wipe the card’s contents, so make sure it doesn’t have anything you need stored
on it. Use SD Card Formatter 4.0 (www.snipca.com/9258)
to format the card.
Now go to www.snipca.com/9319, download the NOOBS
zip file and unpack it to your SD card. The ‘wheezy’ version
(2013-05-25-wheezy-raspbian.zip) is recommended for Raspberry Pi newcomers.
Enter the username ‘pi’ and the password ‘raspberry'.
Remove the SD card from your Windows
computer and insert it into the Raspberry Pi. Since the operating system is on
the SD card, your Pi won't I run without it. Plug in the Pi to turn it on then
select Raspbian as the operating system. This is a version of the Linux Debian
open-source OS that’s been tweaked especially for use on Raspberry Pi
computers.
Controlling your Raspberry Pi
The Raspberry Pi uses a free operating
system based on Linux. Instructions can be given in a range of programming
languages. We're using Python. This is a ‘high level’ programming language in
which the commands approximate to English words. Although the thought of
learning a coding language may sound off-putting, it‘s very easy no follow.
Raspbian boots into a Windows-like desktop, but to get the most out of the
Raspberry Pi you need to use text commands. This text-based approach is
straightforward enough and helps you achieve tasks very quickly.
You’ll soon start to recognize commonly
used commands such as sudo and apt-get. These tell the Pi to treat your
instructions as those of an administrator and to install a ‘package’ (software
and drivers) on your Pi. In the following projects, type the code exactly as
we’ve written it, then press Enter at the end of each command.
Project 1: Set up Wi-Fi and print from your Pi
The Raspberry Pi has only a basic set of
functions. These include the Midori browser and LXTerminal, which is similar to
the command prompt in Windows.
Your Pi will need web access to download
and install other programs as the first thing Raspbian does is check for the
latest version. To add a Model B Pi to your network plug in an Ethernet cable
and attach it directly to your router. On a Model A Pi you need to plug a USB
Wi-Fi dongle (there’s a list of supported devices at www.snipca.com/9318) into your powered
USB hub before you turn on the Pi. Double-click ‘Wi-Fi Config' and choose Manage
Networks. Click Add to see a list of wireless networks. Double-click your network
name to select it, then add your Wi-Fi password and click Add to complete the
setup.
Add
Printer Daspberry CUPS 1.5.3
In order to print from your Pi you’ll need
to install CUPS. Connect your printer to your Raspberry Pi and switch them both
on. Double-click LXTerminal on the desktop. LXTerminal is similar to the
command prompt in Windows. Type sudo apt-get update, press enter then type sudo
apt-get install cups. The installation will take up to 30 minutes – the Pi is
built for experimentation rather than speed.
Once CUPS is installed, add the user pi to
the group allowed to access the printer. Type sudo usermod -a -G Ipadmin pi and
press Enter. To set up the printer double-click Midori and type http://127.0.0.1:631 into the address bar. Now,
click the ‘Adding Printers and Classes’ button and, on the next screen, click
Add Printer. Type the username ‘pi’ and password ‘raspberry’ into the pop-up
box.
Raspbian
Desktop
Select your printer from the list of Local Printers
then click Continue. Click Continue on the Add Printer page, then, on the next
page, choose your printer model from the list. If your exact model isn’t shown,
click the closest equivalent, such as another model of the same name. Next,
click Add Printer, then Set Default Options. Test whether the printer has
installed correctly by clicking Print Test Page under Maintenance.