Скачать книгу

board, so you can plug in a USB keyboard. If you have an older keyboard with a round (PS/2) connector, you can use it, but you’ll need a small adapter plug to convert between PS/2 and USB.

      ✔ SD card: Your Raspberry Pi doesn’t have a hard drive, so you’ll need to use some kind of external storage. An onboard SD card slot is provided for this purpose. When you plug in an SD card, your Raspberry Pi treats it just like a hard drive. SD cards are pretty cheap, so go for one with at least 8GB or 16GB of storage. SD cards have class numbers to indicate how fast they can read and write data. We recommend you get a Class 6 SD card or better.

      ✔ USB hub: If you’re using a Model A Raspberry Pi, you may need a USB hub to connect your keyboard and mouse (see the preceding bullet). If you’re using a Model B, you don’t need a USB hub, but you’ll probably want extra USB inputs into your Pi, because your keyboard and mouse will take up the two USB ports. Make sure to get a USB hub that has its own power source – the Raspberry Pi can provide only limited power output via USB.

      ✔ USB memory stick (not shown): Memory sticks (also called memory keys or flash drives) can provide a great deal of extra storage that is fast and reliable. They’re also handy for moving files from another computer or laptop to your Raspberry Pi.

      ✔ SD card writer (not shown): The Linux operating system for your Raspberry Pi is stored on an SD card. You can buy SD cards with the operating system already loaded, but you’ll probably want to write your own at some point, so you need to make sure your computer has an SD card slot. Most desktops and laptops have one these days, but if yours doesn’t, you should get an SD card writer. It plugs into your USB port and allows your computer to see what’s on the card and write files to it.

      ✔ Speakers (not shown): Your Raspberry Pi has a 3.5mm audio jack so you can plug in headphones or external speakers. If you’re using the HDMI connection and HDMI monitor as a display, the audio is sent over that cable to your screen.

      ✔ Micro USB power supply (not shown): Your Raspberry Pi gets its power via the micro USB connector on the side. You can use just about any power charger that fits this port, but it needs to supply 700 milliamperes (mA) of current (check the specifications printed on the side of the charger). Most good mobile phone chargers will work fine, as long as they supply 5V 700mA (3.5 watts). We recommend a Raspberry Pi–compatible power adapter, which should be available from the supplier of your Raspberry Pi.

       Figure 1-4: Key accessories.

      Setting Up Your Operating System

      To do anything useful with your Raspberry Pi, you need to have an operating system. The operating system provides the basic functions like the GUI, which most people know as the “desktop environment.” It also supports reading and writing files, runs general-purpose applications like your word processor and web browser, and runs the programs you write for your Raspberry Pi projects. Your Raspberry Pi uses the Linux operating system to do this.

      Your operating system is stored on an SD card, not on a hard drive like most computers. When you turn on your Raspberry Pi, it reads the operating system that’s on the SD card. If your card isn’t inserted, the Raspberry Pi won’t be able to start up, so you need to get the operating system onto an SD card before you can do anything else.

      Linux is a free operating system, unlike the ones used on Windows and Mac. It’s an open-source project, which means anyone can contribute to it – and thousands of people do. The Linux Foundation (www.linuxfoundation.org) coordinates these efforts and manages the standard Linux kernel (the core code that makes it work). All you have to do is download a copy of the operating system (see the nearby sidebar) and put it on your SD card.

      tip You also can buy premade SD cards that already have the operating system written onto them. With one of these cards, all you have to do is insert your card and power up your Raspberry Pi. You can buy them from RS, element14, Amazon, eBay, or other online outlets. If you already have one, skip to the section on setting up your hardware, later in this chapter.

      Selecting your Linux distribution

      Because it’s an open project, many different versions of Linux are out there in the wild. These are referred to as Linux distributions (or distros), and you can download them for free. The different distributions are specialized for a variety of purposes. Some are made to be as bare bones as possible; others are optimized for performance.

      The Raspberry Pi Foundation has endorsed a special distribution for beginners called Raspbian Wheezy, which is a version of the Debian Linux distribution. It includes a GUI called the Lightweight X11 Desktop Environment (LXDE). It also supports the programming languages that you use to write code for the projects in this book. Most of the projects use a scripting language called Python; some use a programming language called C. We assume you’re using Raspbian Wheezy for the projects in this book. (Tip: Your operating system is on your SD card, so if you ever want to use something other than Wheezy, you can load it onto an SD card and pop it into the SD card slot.)

      You need to download Raspbian Wheezy so you can copy it to your card. The best place to get it is from the Raspberry Pi website at www.raspberrypi.org/downloads. Click the Download ZIP button next to Raspbian Debian Wheezy and save the file on your system in a place that you can easily find it. After you download Wheezy, you’ll need to unzip the compressed file by clicking it. (Note: If you have a Mac, you don’t need to unzip the file before you create the SD card. Just follow the instructions for Mac later in this chapter.)

      There is also a download file called NOOBS (which stands for “new out of the box software”) on the Raspberry Pi website, which you can use to automate the process of creating an SD card. It’s designed to be really easy to use. You just download NOOBS, unzip it, and put it on your SD card. NOOBS then manages the setup of your Raspberry Pi automatically. Even though NOOBS is supposed to be easy, problems sometimes occur, requiring you to get another program to format your SD card. We think it’s simpler just to download the Raspbian Debian Wheezy and create your SD card yourself in a few easy steps.

      Flashing Your SD Card

      Your operating system is made up of a bunch of files that are run from the SD card itself. However, when you write the operating system’s files to the SD card, they’re written in a special format that Linux can read. You can’t just copy them over as you would with other kinds of files. The Linux distribution you downloaded is in a special format called a disk image. And you flash the disk image to the SD card using a special little program. The program you need depends on whether you’re using Windows, Mac, or Linux.

       Flashing an SD card in Windows

      To create the image file in Windows, you use a special program called Image Writer for Windows. It’s free and pretty easy to use. Just follow these steps:

      1. Insert your SD card into your computer’s SD card slot or, if you don’t have one, into your SD card reader.

      Take note of which drive letter is assigned to your SD card.

      2. Download the files at www.sourceforge.net/projects/win32diskimager/files/latest/download.

      tip If you want more information about Image Writer for Windows, go to www.launchpad.net/win32-image-writer.

      3. Double-click the file to extract it, click Extract All Files to unzip the archive into a folder, and then open the folder.

      

Скачать книгу