Raspberry Pi® User Guide Table of Contents Introduction Programming is fun! A bit of history So what can you do with the Raspberry Pi? Part I: Connecting the Board Chapter 1: Meet the Raspberry Pi ARM vs. x86 Windows vs.
Upgrading Software Chapter 3: Troubleshooting Keyboard and Mouse Diagnostics Power Diagnostics Display Diagnostics Boot Diagnostics Network Diagnostics The Emergency Kernel Chapter 4: Network Configuration Wired Networking Wireless Networking Chapter 5: Partition Management Creating a New Partition Resizing Existing Partitions Automatic Resizing Manual Resizing Moving to a Bigger SD Card Imaging from Linux Imaging from OS X Imaging from Windows Chapter 6: Configuring the Raspberry Pi Hardware Settings—confi
Chapter 7: The Pi as a Home Theatre PC Playing Music at the Console Dedicated HTPC with Rasbmc Streaming Internet Media Streaming Local Network Media Configuring Rasbmc Chapter 8: The Pi as a Productivity Machine Using Cloud-Based Apps Using OpenOffice.
Chapter 12: Hardware Hacking Electronic Equipment Reading Resistor Colour Codes Sourcing Components Online Sources Offline Sources Hobby Specialists The GPIO Port UART Serial Bus I²C Bus SPI Bus Using the GPIO Port in Python Installing the GPIO Python Library GPIO Output: Flashing an LED GPIO Input: Reading a Button Moving Up From the Breadboard A Brief Guide to Soldering Chapter 13: Add-on Boards Ciseco Slice of Pi Adafruit Prototyping Pi Plate Fen Logic Gertboard Part IV: Appendixes Appendix A: Python Rec
Raspberry Pi® User Guide Eben Upton and Gareth Halfacree
Raspberry Pi® User Guide This edition first published 2012 © 2012 Eben Upton and Gareth Halfacree Registered office John Wiley & Sons Ltd., The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.
Editorial and Production VP Consumer and Technology Publishing Director Michelle Leete Associate Director–Book Content Management Martin Tribe Associate Publisher Chris Webb Executive Commissioning Editor Craig Smith Assistant Editor Ellie Scott Project Editor Kathryn Duggan Copy Editor Kathryn Duggan Technical Editor Omer Kilic Editorial Manager Jodi Jensen Senior Project Editor Sara Shlaer Editorial Assistant Leslie Saxman Marketing Associate Marketing Director Louise Breinholt Marketing Manag
Senior Marketing Executive Kate Parrett Composition Services Compositor Erin Zeltner Proofreader Wordsmith Editorial Indexer BIM Indexing & Proofreading Services
About the Authors Eben Upton is a founder and trustee of the Raspberry Pi Foundation, and serves as its Executive Director. He is responsible for the overall software and hardware architecture of the Raspberry Pi, and for the Foundation's relationships with its key suppliers and customers. In an earlier life, he founded two successful mobile games and middleware companies, Ideaworks 3d Ltd. and Podfun Ltd., and held the post of Director of Studies for Computer Science at St John's College, Cambridge.
For my father, the enthusiastic past, and my daughter, the exciting future.
Introduction “Children today are digital natives”, said a man I got talking to at a fireworks party last year. “I don’t understand why you’re making this thing. My kids know more about setting up our PC than I do.” I asked him if they could program, to which he replied: “Why would they want to? The computers do all the stuff they need for them already, don’t they? Isn’t that the point?” As it happens, plenty of kids today aren’t digital natives.
This is the sort of situation I want to see the back of, where potential and enthusiasm is squandered to no purpose. Now, obviously, I’m not monomaniacal enough to imagine that simply making the Raspberry Pi is enough to effect all the changes that are needed. But I do believe that it can act as a catalyst.
of design by committee I’ve seen, and to be honest, I hated it at first. (I have since come to love the name, because it works really well—but it took a bit of getting used to since I’d been calling the project the “ABC Micro” in my head for years.) It’s “Raspberry” because there’s a long tradition of fruit names in computer companies (besides the obvious, there are the old Tangerine and Apricot computers—and we like to think of the Acorn as a fruit as well).
Our Community The Raspberry Pi community is one of the things we’re proudest of. We started with a very bare-bones blog at www.raspberrypi.org just after Rory’s May 2011 video, and put up a forum on the same website shortly after that. That forum now has more than 20,000 members—between them they’ve contributed more than 100,000 posts of wit and wisdom about the Raspberry Pi.
of fun to be had out there.
Part I: Connecting the Board Chapter 1: Meet the Raspberry Pi Chapter 2: Linux System Administration Chapter 3: Troubleshooting Chapter 4: Network Configuration Chapter 5: Partition Management Chapter 6: Configuring the Raspberry Pi
Chapter 1: Meet the Raspberry Pi Your Raspberry Pi board is a miniature marvel, packing considerable computing power into a footprint no larger than a credit card. It’s capable of some amazing things, but there are a few things you’re going to need to know before you plunge head-first into the bramble patch. If you’re eager to get started, skip ahead a couple of pages to find out how to connect your Raspberry Pi to a display, keyboard and mouse. ARM vs.
for ARMv7, like software developed for x86, is sadly not compatible with the Raspberry Pi’s BCM2835—although developers can usually convert the software to make it suitable. That’s not to say you’re going to be restricted in your choices. As you’ll discover later in the book, there is plenty of software available for the ARMv6 instruction set, and as the Raspberry Pi’s popularity continues to grow, that will only increase.
Figure 1-2: The yellow RCA phono connector, for composite video output When no other display device is available, a composite video connection will get you started with the Pi. The quality, however, isn’t great. Composite video connections are significantly more prone to interference, lack clarity and run at a limited resolution, meaning that you can fit fewer icons and lines of text on the screen at once.
If your monitor has a VGA input—a D-shaped connector with 15 pins, typically coloured silver and blue—the Raspberry Pi can’t connect to it. Adapters are available that will take in a digital DVI signal and convert it to an analogue VGA signal, but these are expensive and bulky. The best option here is simply to buy a more-modern monitor with a DVI or HDMI input.
available at consumer electronics shops, or can be purchased even cheaper at online retailers such as Amazon. Connecting a Keyboard and Mouse Now that you’ve got your Raspberry Pi’s output devices sorted, it’s time to think about input. As a bare minimum, you’re going to need a keyboard, and for the majority of users, a mouse or trackball is a necessity too.
purchased one of these, or received it in a bundle with your Pi, you can simply plug it in to the SD card slot on the bottom side of the left-hand edge. If not, you’ll need to install an operating system—known as flashing—onto the card before it’s ready to go. Some SD cards work better than others, with some models refusing to work at all with the Raspberry Pi. For an up-to-date list of SD card models known to work with the Pi, visit the eLinux Wiki page: http://www.elinux.
Figure 1-5: Flashing the SD card using the dd command in Linux Flashing from OS X If your current PC is a Mac running Apple OS X, you’ll be pleased to hear that things are as simple as with Linux. Thanks to a similar ancestry, OS X and Linux both contain the dd utility, which you can use to flash the system image to your blank SD card as follows: 1. Select Utilities from the Application menu, and then click on the Terminal application. 2. Plug your blank SD card into a card reader connected to the Mac. 3.
drive letter to choose, open My Computer or Windows Explorer to check. 6. Click the Write button to flash the image file to the SD card. This process takes a while, so be patient! No matter which operating system you’re writing from, it’s important to ensure you leave the SD card connected until the image has been completely written. If you don’t, you may find that Pi doesn’t boot when the SD card is connected. If this happens, start the process again.
Don’t be tempted to go for a gigabit-class adapter, which will be referred to as a 10/100/1000 USB Ethernet adapter. Standard USB ports, as used on the Raspberry Pi, can’t cope with the speed of a gigabit Ethernet connection, and you’ll see no benefit to the more expensive adapter. Wired Networking To get your Raspberry Pi on the network, you’ll need to connect an RJ45 Ethernet patch cable between the Pi and a switch, router or hub.
Figure 1-8: Two USB wireless adapters, suitable for use with the Raspberry Pi Using such a device, the Pi can connect to a wide range of wireless networks, including those running on the latest 802.11n highspeed standard. Before purchasing a USB wireless adapter, check the following: • Ensure that Linux is listed as a supported operating system. Some wireless adapters are provided with drivers for Windows and OS X only, making them incompatible with the Raspberry Pi.
Chapter 2: Linux System Administration The majority of modern Linux distributions are user-friendly, with a graphical user interface (GUI) that provides an easy way to perform common tasks. It is, however, quite different to both Windows and OS X, so if you’re going to get the most out of your Raspberry Pi, you’ll need a quick primer in using the operating system.
Package A collection of files required to run an application, typically handled by the package manager. Package manager A tool for keeping track of, and installing new, software. Partition A section of a hard drive which is ready to have a file system applied to it for storage. Root The main user account in Linux, equivalent to the Windows administrator account. Shell A text-based command prompt, loaded in a terminal. sudo A program that allows restricted users to run a command as the root user.
The software provided with the Debian distribution is split into themed categories. To view these categories, you can left-click the menu icon, located on the bottom-left of the screen in LXDE (see Figure 2-1). Figure 2-1: The LXDE desktop, as loaded on the Debian Raspberry Pi distribution The following lists describe the software packages, grouped by category.
• IDLE—An integrated development environment (IDE) written specifically for Python. You’ll learn more about using IDLE to write your own Python programs in Chapter 11, “An Introduction to Python”. • IDLE 3—Clicking this entry loads IDLE configured to use the newer Python 3 programming language, rather than the default Python 2.7 language. Both are largely compatible with each other, but some programs may require features of Python 3.
Before these external devices are accessible, however, the operating system needs to know about them. In Linux, this process is known as mounting. If you’re running a version of Linux with a desktop environment loaded—like the recommended Debian distribution’s LXDE, loaded from the console with the startx command—this process is automatic. Simply connect the device to a free USB port on the Pi or a USB hub, and the device and its contents will be immediately accessible (see Figure 2-2).
used to log on to the Pi initially. Just follow these steps: 1. Log in to the Pi using the existing user account (user name pi and password raspberry if you’re using the recommended Debian distribution). 2. Type the following as a single line: sudo useradd -m -G adm,dialout,cdrom,audio,plugdev,users, lpadmin,sambashare,vchiq,powerdev username This creates a new, blank user account. Note that the command should be typed as a single line, with no spaces after the commas. 3.
The directories visible on the default Debian distribution are as follows: • boot—This contains the Linux kernel and other packages needed to start the Pi. • bin—Operating system-related binary files, like those required to run the GUI, are stored here. • dev—This is a virtual directory, which doesn’t actually exist on the SD card. All the devices connected to the system— including storage devices, the sound card and the HDMI port—can be accessed from here.
The second partition is far larger and formatted as EXT4, a native Linux file system designed for high-speed access and data safety. This partition contains the main chunk of the distribution. All the programs, the desktop, the users’ files and any software that you install yourself are stored here. This takes up the bulk of the SD card.
If your search term brings up too many different packages to see on a single screen display, you can tell Linux that you want it to pause on each screenfull by piping the output of apt-cache through a tool called less. Simply change the command to apt-cache search game | less and use the cursor keys to scroll through the list. Press the letter Q on the keyboard to exit. Installing Software Once you know the name of the package you want to install, switch to the apt-get command in order to install it.
Uninstalling Software If you decide you no longer want a piece of software, apt-get also includes a remove command that cleanly uninstalls the package along with any dependencies which are no longer required. When you’re using a smaller SD card with the Pi, the ability to try out software and quickly remove it is extremely useful.
man apt at the terminal.
Chapter 3: Troubleshooting Sometimes, things don’t go entirely smoothly. The more complex the device, the more complex the problems that can occur— and the Pi is an extremely complex device indeed. Thankfully, many of the most common problems are straightforward to diagnose and fix. In this chapter, we’ll look at some of the most common reasons for the Pi to misbehave and how to fix them.
relatively easy way to check if this is the case in the form of two voltage test points. To use the voltage test points, you’ll need a voltmeter or multimeter with direct current (DC) voltage measuring capabilities. If your meter has multiple inputs for different voltages, use an appropriate setting. Avoid touching the test probes to anything not labelled as a test point. It’s possible to bridge the 5 V supply that comes in to the Pi to the internal 3.
adjust this setting in Chapter 6, “Configuring the Raspberry Pi”. When you use the HDMI output, the display type is usually automatically detected. If you’re using an HDMI to DVI adapter to plug the Pi into a computer monitor, however, this occasionally goes awry. Common symptoms include snow-like static, missing picture portions or no display at all. To fix this, note the resolution and refresh rate of your connected display, and then jump to Chapter 6 to find out how to set these manually.
The output of ifconfig is split into the following sections: • Link encap—The type of encapsulation used by the network, which on the Model B will either read Ethernet for the physical network port or Local Loopback for the virtual loopback adaptor. • Hwaddr—The Media Access Control (MAC) address of the network interface, written in hexadecimal. This is unique for every device on the network, and each Pi has its own MAC address, which is set at the factory.
You can test the networking by using the ping command, which sends data to a remote computer and waits for a response. If everything’s working, you should see the same response as shown in Figure 3-3. If not, you may need to manually configure your network settings, which you’ll learn how to do in Chapter 4, “Network Configuration”.
kernel=kernel_emergency.img This tells the Pi that it should load the kernel named kernel_emergency.img instead of the usual kernel.img. Reversing the process is as simple as opening cmdline.txt again and removing the entry. You’ll learn more about cmdline.txt and how it affects the operation of the Raspberry Pi in Chapter 6, “Configuring the Raspberry Pi”.
Chapter 4: Network Configuration For most users, configuring the Pi’s network is as easy as plugging a cable into the Model B’s Ethernet port—or a USB Ethernet adapter in the case of the Model A. For others, however, the network requires manual configuration. If you know that your network doesn’t have a Dynamic Host Configuration Protocol (DHCP) server—a system that tells the Pi and other devices on the network how they should connect—or if you want to use a USB wireless adapter with the Pi, read on.
When you’ve finished editing the file, press CTRL + O to save it, and then press CTRL + X to leave nano and return to the terminal. To use your new network settings, restart the networking service by typing the following: sudo /etc/init.d/networking restart If you need to return to automatic settings via DHCP, you need to edit the interfaces file again and delete the address, netmask and gateway settings. Replace static with dhcp at the end of the iface line, and then restart the networking service again.
Then test the settings by either opening a web browser or using the following ping command (see Figure 4-2): ping -c 1 www.raspberrypi.org Figure 4-2: A successful test of networking on the Raspberry Pi Model B Wireless Networking Although no current models of the Raspberry Pi include Wi-Fi networking hardware onboard, it’s possible to add wireless connectivity with a simple USB Wi-Fi adapter. However, you will need to configure the adapter before you can use it to get your Pi online.
The kernel ring buffer is a special portion of memory used by the Linux kernel to store its human-readable output. It’s an important part of the Linux operating system: the text flashes by too quickly to read while the Pi boots, so it’s critical that users are able to view the messages at a later date to read errors and diagnose problems. With the adapter connected but no wireless firmware packages installed, the kernel will print a series of error messages to the ring buffer.
If apt-cache fails to find the firmware, you may need to make a guess based on the firmware packages in the following list. Don’t worry if you install the wrong one—any firmware can be quickly uninstalled using apt-get remove, and having multiple firmware packages does no harm.
You can check the current status of the network using the iwconfig command. Like ifconfig, the iwconfig command allows you to check the status of a network interface and issue configuration commands. Unlike ifconfig, however, iwconfig is specifically designed for wireless networks and includes specific features for this.
set by the access point on connection. • Power Management—The current status of the adapter’s power management functionality, which reduces the device’s power demands when the wireless network is idle. This has little effect on the Pi, but is typically enabled for battery-powered devices like a laptop. Figure 4-5: The output of iwconfig when not connected to a wireless network To connect the Pi to a wireless network, you will need to add some lines into the /etc/network/interfaces file.
Once the entry is in place, save the file by pressing CTRL + O and then quit nano with CTRL + X. The device ID of wlan0 is correct if this is the first wireless device you’ve set up on your Pi. If it isn’t, the number at the end will be different. Type iwconfig to see a current list of wireless devices, and change the lines in the preceding code example accordingly. The last line of the interfaces file makes reference to a configuration file, wpa.conf, which does not yet exist.
[Tab] key_mgmt=NONE [Tab] wep_key0=”Your_WEP_Key” } Replace Your_WEP_Key with the ASCII key for your wireless network’s WEP encryption. Save the file with CTRL + O, and then exit nano with CTRL + X. WEP encryption is extremely insecure. Readily-available software can break the encryption on a WEP-protected network in just a few minutes, allowing a third party to use your network. If you’re still running WEP, consider switching to WPA or WPA2 for better security.
Chapter 5: Partition Management Having the Raspberry Pi’s operating system provided as an image of somebody else’s SD card is convenient, but a little inflexible. Most distribution images available for download assume a 2 GB or 4 GB SD card, meaning that people with 8 GB or larger cards find much of their space wasted. Creating a New Partition One way to make the most of a large SD on the Raspberry Pi is to create a new partition in the empty space at the end of the card.
Enter to accept this. 6. The next prompt will ask you how big the partition should be, in megabytes (MB). The default is to create a partition that fills the entire available free space on the device, so again, just press Enter. 7. Next, the new details—known as a partition table—need to be written to the disk. Use the cursor keys to move the option selection highlight to Write and press Enter. 8. You will be prompted to make sure that the changes are correct.
which mount points. This table may look complicated at first glance, but its layout follows a logical tabular pattern. From left to right, the columns tell Linux the location of the device to be mounted, the directory where the device should be accessible (the mount point), the file system type, any options required, and finally, two numbers that control whether the file system should be dumped in the event of a system problem and whether it should be checked by the fsck (file system check) tool.
To resize the root file system using the raspi-config tool, follow these instructions: 1. If this is the first time you have loaded Debian on the Raspberry Pi, raspi-config will load automatically. If it does not, type sudo raspi-config at the console or terminal to load the tool manually. 2. In the raspi-config menu (see Figure 5-3), press the down arrow on the keyboard to highlight the expand_rootfs option and then press Enter. Figure 5-3: The raspi-config tool’s menu screen 3.
By default, the partition editor will look at the first drive it finds in your system, which is usually your PC’s hard drive. You don’t want to make changes to that, so make sure to click on the device selector in the top-right corner and choose the device corresponding to the SD card. On a single-drive system, this will usually be /dev/sdb (see Figure 5-5). Figure 5-5: Parted Magic’s Partition Editor tool, before resizing the partition Resizing and moving partitions is a risky process.
swap in the partition editor. If this is present, continue with these instructions; if not, skip straight to step 5. 2. Click on the swap partition, which will be the last partition in the list, and choose Resize/Move from the toolbar. 3. In the dialogue box that appears, click and drag the box at the top left over to the top right (see Figure 5-6). Once complete, the Free Space Following box should read 0. Figure 5-6: Moving the swap partition in the partition editor 4.
Moving to a Bigger SD Card If you’ve been using the Pi for a while, you may find that the 4 GB SD card you thought would be large enough for your needs has become full. Buying a new SD card with 8 GB, 16 GB or even more storage is cheap enough, but you don’t want to lose your files. Thankfully, it’s pretty straightforward to move the contents of your existing SD card across to a bigger card.
Imaging from OS X Imaging the Pi’s SD card on OS X is almost exactly the same as flashing the SD card was back in Chapter 1. Again, make sure you have enough hard disk space to hold a file the size of the SD card. Then follow these steps: 1. Select Utilities from the Application menu, and then click on the Terminal application. 2. Plug your Pi’s smaller SD card into a card reader connected to the PC. 3. Type diskutil list to see a list of storage devices.
Now that you have your disk image, use the instructions on flashing an SD card from Chapter 1, “Meet the Raspberry Pi”, to write it to the new card. Remember that writing an image takes time, so be patient and let it finish fully. When the image writing has finished, you’ll have two SD cards containing the exact same data, including the same partition table. This means that while the new card might be 16 GB or 32 GB, the Pi will only be able to access the same 2 GB or 4 GB of the original card.
Chapter 6: Configuring the Raspberry Pi Because of its origins in embedded computing, the BCM2835 chip at the heart of the Raspberry Pi doesn’t have anything like a PC’s BIOS menu where various low-level system settings can be configured. Instead, it relies on text files containing configuration strings that are loaded by the chip when the power is switched on. Before taking a look at the various options available in these files—config.txt, cmdline.txt and start.
Modifying the Display Usually, the Raspberry Pi will detect the type of display that’s connected and alter its settings accordingly. Sometimes, however, this automatic detection doesn’t work. This is often the case when a Raspberry Pi from one country is connected to an older TV from another country. If you connect your Pi to your TV and there’s nothing to see, you may need to override these defaults. Various settings in the config.txt file can be used to improve or alter the video output.
value of 0 allows the Pi to attempt to detect the display, while a value of 1 forces the Pi to use HDMI regardless. • hdmi_group—Sets the HDMI group mode to CEA or DMT. You should change this setting according to the display type you’re trying to connect, before using hdmi_mode to control the output resolution and frequency. The two possible values are: • 1—Sets the HDMI group to that defined by the Consumer Electronics Association of America (CEA).
the chip in other ways as well. In particular, it allows you to alter the speed at which the chip runs, increasing its performance at the expense of the part’s lifespan—a process known as overclocking. Adjusting any of the settings listed in this section can result in damage to your Pi.
To return the settings to normal, you can either delete the entire config.txt file or—if you’re using it to control the display settings as well—simply delete the lines that deal with overclocking, and then restart the Pi. Overvoltage Settings If you’re overclocking your Pi, you will eventually hit a brick wall past which the device won’t go.
Using config.txt, you can tell the BCM2835 to allow its CPU portion access to the L2 cache memory. In some cases, this can improve performance. In other cases, this can harm performance, due to the physical location of the cache being a relatively long distance away from the CPU section of the chip and closer to the GPU. Use of the L2 cache memory also requires a Linux distribution that has been compiled with the cache memory in mind.
The first file, arm128_start.elf, is configured to split the memory down the middle, with 128 MB available to the BCM2835’s ARM CPU and 128 MB available to the VideoCore IV GPU. The second and third files gradually reduce the amount of memory available to the GPU. arm192_start.elf gives 192 MB to the CPU and 64 MB to the GPU, while arm224_start.elf gives 224 MB to the CPU and 32 MB to the GPU.
In a Linux-based desktop or laptop, these options are normally passed to the kernel by a tool known as a bootloader, which has its own configuration file. On the Pi, the options are simply entered directly into cmdline.txt to be read by the Pi at startup. Almost any kernel option supported by Linux can be entered into the cmdline.txt file, to alter things like the appearance of the console or which kernel is loaded. As an example, here is the cmdline.
root file system is available. Without this option, the Pi can get stuck as it begins to boot before the relatively slow SD card is fully ready for access. With the exception of the dwc_otg setting, none of these kernel parameters are unique to the Pi. The bootloader configuration of any Linux distribution will include a list of options very similar to those of cmdline.txt. Typically, you should leave the cmdline.txt alone.
Part II: Using the Pi as a Media Centre, Productivity Machine and Web Server Chapter 7: The Pi as a Home Theatre PC Chapter 8: The Pi as a Productivity Machine Chapter 9: The Pi as a Web Server
Chapter 7: The Pi as a Home Theatre PC One of the most popular tasks for a Pi to carry out is that of a home theatre PC, or HTPC. The Broadcom BCM2835 at the Pi’s heart is specifically designed as a multimedia powerhouse, originally developed for use in HTPCs. The graphics portion of the BCM2835 system-on-chip (SoC) design, a Broadcom VideoCore IV module, is capable of fullspeed high-definition video playback using the popular H.264 format.
Where the power of mocp becomes apparent is when you exit the application by pressing the Q key. If mocp is in the middle of playing back music, it will continue to do so even as you use the console or terminal window for other tasks. Running the mocp command again will restore the interface, allowing you to change songs, pause or stop playback. You can also control mocp directly from the terminal, without having to use the interface.
instructions from Chapter 1, “Meet the Raspberry Pi”, it’s not necessary to do so. If you already have an SD card you use with the Pi, be aware that installing Rasbmc on it will delete the contents of the card. Back up any files you want to keep, or if you want to be able to switch between the two distributions, buy a second SD card specifically for Rasbmc use.
Scroll through the list with the mouse or cursor keys, and click on an entry or press the Enter key to access more information. To install an add-on, just click Install from the pop-up information box that appears when you click on an entry in the list. This will download the add-on from the Internet and automatically install it into Xbmc. Watch out for add-ons listed as Broken—these have been reported as not working correctly, and should not be installed until the problem is fixed by the add-on developer.
Similar add-ons are available under the Music and Video menus, and operate in the same way. Using these add-ons, you can view picture content and stream audio content from sites such as Flickr, Picasa, The Big Picture, Grooveshark, Sky.fm and SoundCloud. Streaming Local Network Media The Xbmc software supports the Universal Plug and Play (UPnP) media streaming standard, allowing it to connect to a range of devices on your home network.
Figure 7-6: Adding a UPnP music source to Xbmc You can also use the same menu to add an external hard drive as a source to Xbmc by selecting its entry in the initial list. Most external drives will appear automatically, and do not need to be added explicitly—you only need to add a drive as a source if its contents do not appear in Xbmc’s menus.
The Programs menu on the home screen provides access to the Rasbmc Settings menu (shown in Figure 7-7) where network settings, software upgrade settings and various system settings can be adjusted. Normally, this menu can be ignored—however, if you’re having problems connecting to the Internet or the Rasbmc system is continuously crashing, the Programs menu can provide important tools for resolving the issue. Clicking the Rasbmc Settings option under the Programs menu will open a window with three tabs.
Chapter 8: The Pi as a Productivity Machine The flexibility of the Raspberry Pi makes it a good choice as a low-power general-purpose desktop computer. Although it will never reach the same levels of performance as a standard desktop or laptop, its low cost and environmentally-friendly power consumption help to make up for any problems with occasionally sluggish performance.
• Zoho—With five million registered users, Zoho is another popular choice. As with Google Drive, a word processor, spreadsheet and presentation package are included, but Zoho also offers enhanced business-centric features like a wikibased knowledge base system, web conferencing, financial management and even customer relationship management. Many of the advanced features, however, require a paid account. You can access the service at http://www.zoho.com.
Using OpenOffice.org If you would prefer not to use a cloud-based service, the alternative is to install OpenOffice.org. Designed as an open-source, cross-platform alternative to the popular Microsoft Office suite, OpenOffice.org is powerful and offers just as much functionality as its closed-source inspiration. That functionality comes at a cost, however. The OpenOffice.org package is large, taking up nearly 400 MB of space on the Pi’s SD card once all the dependencies are included.
By default, OpenOffice.org saves and loads files in a format known as the Open Document Format (ODF). This is a standardsbased, royalty-free file format supported by the majority of office suite packages—including newer versions of Microsoft Office. When saving a file in OpenOffice.org, you can change the format using a drop-down menu in the Save As dialogue. Under File Type, you can select a variety of formats, including several which are fully compatible with older versions of Microsoft Office.
The Gimp is not installed by default in most Raspberry Pi distributions, so you’ll have to connect your Pi to the Internet and install it through the package management system (see Chapter 2, “Linux System Administration”, for details). The Gimp takes up quite a lot of space on the SD card—although not as much as OpenOffice.org—so make sure you have enough free space before installing it.
Chapter 9: The Pi as a Web Server Although the Pi is significantly less powerful than most devices you would find in a data centre, that doesn’t mean that it can’t act as a useful server in a home or business environment. Despite a small amount of memory and relatively underpowered processor, the Pi’s low power draw and silent running makes it a great choice for serving low-traffic simple pages to a local network or even out onto the Internet.
Figure 9-2: Choosing a password for MySQL When the software installation has finished, both the MySQL and Apache servers—known in Linux parlance as daemons—will be running in the background. To check that the server is working correctly, use another computer on the network to connect to the Raspberry Pi using a web browser. In the address bar, type the IP address of the Pi to display the default Apache installation page (see Figure 9-3).
The final step is to confirm that the PHP scripting module is loaded correctly in Apache. This module is important: it allows the Apache web server to run PHP scripts to serve dynamic content. Without a working PHP module—or an alternative module for another scripting language like Python—Apache is only able to server static pages. To test the Apache PHP module, create a new PHP script file using the following command, typed as a single line: sudo sh -c ‘echo “” > /var/www/phptest.
When you’ve finished testing, remove the phptest.php file with the following command: sudo rm /var/www/phptest.php Although Apache is the most common web server, there are others. If you find the performance of Apache too slow, experiment with lighttpd—a lightweight web server designed to use less memory than Apache. It can be installed under Debian with the command sudo apt-get install lighttpd. With the LAMP stack installed and working, you can now create your own websites that will be served by the Pi.
Linking a file or directory is different to moving: the files for WordPress now exist in both /usr/share and /var/www simultaneously, without taking up any extra space on the Pi’s SD card. If you’ve told Apache to use a different directory for the default website, change the linking command accordingly.
Before you can access WordPress from another computer, you’ll need to create an additional configuration file. This is created by linking the existing configuration file—set up for local access—using the following command, typed as a single line: sudo ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-ipaddress.php Replace ipaddress in this code with the IP address of your Raspberry Pi.
The WordPress software includes an automatic update feature, which ensures that your installation is running the latest version. Because of its popularity, WordPress is often the target of malware attacks, and frequent updates are released to patch security holes or add new features. However, when installed via APT, WordPress lacks the permissions required to keep itself up-todate.
Part III: Programming and Hacking Chapter 10: An Introduction to Scratch Chapter 11: An Introduction to Python Chapter 12: Hardware Hacking Chapter 13: Add-on Boards
Chapter 10: An Introduction to Scratch So far in this book, you’ve learned a lot about how to use programs that other people have written on your Raspberry Pi. The chief goal of the Raspberry Pi project is to get people writing their own programs, however—and not just adults. The Raspberry Pi Foundation is working to get the device adopted as an educational tool for all age ranges.
To get the user started, a new Scratch project already includes a blank stage and a single sprite. What it lacks is a program, so clicking the green flag icon at the top-right of the window achieves nothing, because Scratch doesn’t yet know what you want it to do. For the Hello World program, you’ll need to change the blocks palette at the left of the screen to the Looks mode by clicking on its button.
Enter this section now by clicking Control, and then drag the top entry—marked when [flag icon] clicked—and place it just above the purple say brick (see Figure 10-3). If you drop it close enough, it should automatically join to the existing brick like a jigsaw piece. Figure 10-3: A Control block joined to a Looks block in Scratch This concept of connecting multiple bricks together is the heart of Scratch. If you look at the Control brick you just placed, you’ll see there’s no connecting hole at the top.
Example 2: Animation and Sound While Hello World is a very traditional example, it’s not particularly interesting. It also fails to show off the true power of Scratch, which lies in its impressive multimedia capabilities and sprite-handling system. This system is particularly well suited to simple animations, which can form the basis of an interactive game. To begin, start a new project in Scratch by either loading the program afresh or choosing New from the File menu.
This simple animation program can be extended in a variety of ways. Using the New Sprite option just below the stage on the right side of the Scratch window allows the programmer to add more sprites that can move and play sounds independently. Adding in the say block from the first example—or the similar think block, which creates a thought bubble rather than a speech bubble—allows for the creation of an animated comic strip.
Example 3: A Simple Game Using Scratch for simple animation is one thing, but the software also allows users to read inputs from the keyboard to introduce interactivity. By combining some simple animation controls to the previously described program, you can create a simple game— and, at the same time, introduce the concepts of sprite collision, if statements and input.
The Scratch language is naturally multi-threaded and partially object-oriented. This means that each object in the program, including sprites, can have its own code attached, and that each section of code runs simultaneously and independently of any other block. Used properly, these features allow for some quite complex programs to be created.
bottom, and it’s shaped like a diamond—the same shape used for a decision point in a flowchart. That’s no accident: the majority of the Sensing blocks need to be embedded in a Control block in order to operate. Switch the Blocks pallete to Control mode, and look for the if block—it’s shaped like a squished and bumpy letter C. Note that the if block has a diamond-shaped indentation—the same shape as the touching Sprite1? block.
Drag another if block from the Control palette along with another touching ? sensing block, and this time, change the Sensing block so both blocks together read if touching Sprite2?. Into this block, insert a wait 1 secs Control block with the value changed to 2 and a say Hello! for 2 secs Looks block with the message changed to read Yum-yum-yum!. Finally, drag the whole stacked block up so it connects to the bottom of the existing when right arrow key pressed block, beneath the move 10 steps block.
USB connection. The latter is supported by the Raspberry Pi. Simply connect it to a free USB port or a port on a USB hub connected to the Pi, restart Scratch, and you’ll be able to use its various functions within the Scratch interface. Details on the PicoBoard can be found at http://www.sparkfun.com/products/10311. Robotics with LEGO In addition to add-in sensor modules, it’s possible to control an external robotics system through Scratch.
Chapter 11: An Introduction to Python The Raspberry Pi gets the first half of its name from a long-standing tradition of using fruit to name new computing systems— from classic microcomputers like the Acorn, Apricot and Tangerine to more recognisably modern brands including Apple and BlackBerry—but the second half comes courtesy of the Python programming language.
Choosing IDLE 3 from the Programming menu instead of IDLE loads the Python 3.0 version. This includes features not available in the version of Python used by IDLE, but none of those features are used in this chapter. You can safely load either version, and these examples will still work. It’s good practice to start all Python programs with a line known as a shebang, which gets its name from the # and ! characters at the beginning of the line.
Before you run your program, save it as helloworld.py using the File menu. If you’re using IDLE, the file will be given the extension .py automatically. If you’re using a text editor, be sure to type .py at the end of the filename (not .txt) when you save it. This extension indicates that the file contains Python code—although Python is clever enough to run the program even if it’s saved with a different file extension. How you run the file will depend on whether you’re using IDLE or a text editor.
Making Python Programs Executable Normally, the only way to run a Python program is to tell the Python software to open the file. With the shebang line at the top of the file, however, it’s possible to execute the file directly without having to call Python first. This can be a useful way of making your own tools that can be executed at the terminal: once copied into a location in the system’s $PATH environment variable, the Python program can be called simply by typing its name.
only the basics and fails to introduce some of the concepts required for creating useful or interesting programs. The next example, however, uses some of the basic tools required to make interactive programs in Python.
Previously, you’ve been using a single equals symbol to set the value of variables. The while loop, however, uses two. Using two equals symbols next to each other performs an evaluation, which compares a variable’s value to whatever follows. A single equals symbol instead sets the variable to the value that follows.
firstNumber + secondNumber print firstNumber, “minus”, secondNumber, “equals”, firstNumber - secondNumber print firstNumber, “multiplied by”, secondNumber, “equals”, firstNumber * secondNumber goAgain = int(raw_input(“Type 1 to enter more numbers, or any other number to quit: “)) Save the program as calculator.py, and run it by choosing Run Module from the Run menu in IDLE or by typing python calculator.py at the terminal.
import pygame, sys, time, random from pygame.locals import * The first line imports the main pygame module along with the Python modules sys, time and random, which will also be used in this program. Typically, a module must then be called by typing its name followed by a full stop and the name of the instruction from within the module, but the second line in the preceding code tells Python to load all the instructions from the pygame.locals module as though they’re native instructions.
—if you’re using IDLE, these spaces will be inserted automatically, but if you’re using a text editor, you will need to insert the spaces yourself. After the final line of the function—sys.exit()—you can stop indenting. The gameOver function uses a selection of pygame’s commands to perform a simple task: write the words Game Over to the screen in a large font, pause for 5 seconds, and then quit both pygame and Python itself.
travelling—stored in direction. If they are opposite directions, the instruction is ignored and the snake continues in the same direction as before.
At this point in the program, it’s possible that the player has eaten a raspberry. A game in which only a single raspberry is available is boring, so type the following lines to add a new raspberry back to the playing surface if the player has eaten the existing raspberry: if raspberrySpawned == 0: x = random.randrange(1,32) y = random.
make sure you’re ready! Figure 11-6: Playing Raspberry Snake on the Raspberry Pi A full copy of the program listing for Raspberry Snake is included in Appendix A, “Python Recipes”, and on the Raspberry Pi User Guide website at http://www.wiley.com/go/raspberrypiuserguide. Downloading the source code from the website will save you some typing, but entering the code by hand is a good way of ensuring that you understand what each section does.
practice to use all-capital letters for their names—that way it’s easy to see at glance whether a particular section of the code is using a constant or a variable. Type the following two lines into the program: RPL_NAMREPLY = ‘353’ RPL_ENDOFNAMES = ‘366’ These are IRC status codes, provided by the server to indicate when particular operations have completed. These are used by the program to know when it has received the required list of names from the IRC server.
names in a channel, however, you need to identify yourself to the server and issue some commands using the send function of the socket module. Type the following lines into the program: s.send(‘NICK %(nick)s\r\n’ % user) s.send(‘USER %(username)s %(hostname)s %(servername)s :%(realname)s\r\n’ % user) s.send(‘JOIN %(channel)s\r\n’ % irc) s.
of the program: 353, which means a list of names follows, and 366, which means the list has ended. The if statement looks for the first of these responses, and then uses the split function to retrieve these names and add them to the names list. Now, the names list contains all the names received from the server in response to the program’s query. This may not be all the names, however: until the 366 response, which signals the end of the member names, is received, the list is incomplete.
Hopefully, this chapter has given you a taste of what you can do with Python. It’s far from exhaustive—to do the language full justice would take a considerably larger book. However, there are plenty of resources out there for learning more about the Python language, including the following: • The official Beginner’s Guide to Python, which you can access at http://wiki.python.org/moin/BeginnersGuide. • A free, interactive tutorial that runs entirely in your browser is available for download at http://www.
Chapter 12: Hardware Hacking In earlier chapters, you learned how the Raspberry Pi can be turned into a flexible platform for running a variety of software. In this, it’s not alone: any desktop or laptop can run the same software, and in many cases run it far faster than the Pi’s lowpower processor can manage.
yours didn’t, buy a separate stand-and-sponge set. • Side Cutters—Through-hole components have long legs, which are left sticking out after you’ve soldered them in place. Side cutters allow you to cleanly and quickly trim these excess legs without damaging the solder joint. • Tweezers—Electronics components can be small and fiddly, and a good pair of tweezers is invaluable.
To read the example resistor, first take the two resistance bands starting from the left: these are coloured red and red. Red, on the table included in Figure 12-1, equates to the value 2, so the initial reading is 22. The next band is green, which is the multiplier and equates to 105 or 100,000 (10 followed by five zeros). Multiplying 22 by 100,000 equals 2,200,000, which is the resistance value in ohms: 2,200,000 Ω. There are 1,000 ohms in a kiloohm, and 1,000 kiloohms in a megaohm.
Two of the largest retailers of electronic components and tools in the world are RS Components and Farnell. Both operate offices and warehouses across the world, and both have a substantial selection of hardware from which to choose. Chances are you’re familiar with at least one of the two retailers.
Many of these hobby shops sprang up in the wake of the Arduino, an open-source project to create an educational-friendly microcontroller prototyping platform. With the Raspberry Pi appealing to much the same audience as the Arduino—albeit for very different tasks—the majority are investigating support for the Pi in addition to their existing product lines. Buying from a hobby specialist has several advantages.
numbering pins, and because there are no markings on the Pi itself, it’s easy to get confused as to which pin is which. Never connect anything to the pins marked Do Not Connect; these are reserved for internal functions of the Pi’s BCM2835 system-on-chip (SoC) hardware. Connecting anything to these will result in damage to the Pi. Although the Pi’s GPIO port provides a 5 V power supply, tapped from the incoming power on the micro-USB hub, on Pin 2, the Pi’s internal workings are based on 3.3 V logic.
Although additional buses are present in the Raspberry Pi’s BCM2835 SoC processor, they are not brought out to the GPIO port and are thus unavailable for use. Using the GPIO Port in Python With the theory out of the way, it’s time to get practical. In this section, you’ll learn how to install a library to allow easy access to the general-purpose pins on the Raspberry Pi’s GPIO port in Python.
An LED needs a current limiting resistor to protect it from burning out. Without a resistor, an LED will likely only work for a short time before failing and needing to be replaced. Knowing a resistor is required is one thing, but it’s also important to pick the right resistor for the job. Too high a value and the LED will be extremely dim or fail to light at all; too low a value and it will burn out. To calculate the resistor value required, you will need to know the forward current of your LED.
At this point, nothing will happen. That’s perfectly normal: by default, the Raspberry Pi’s GPIO pins are switched off. If you want to check your circuit immediately, move the wire from Pin 11 to Pin 1 to make the LED light up. Be careful not to connect it to Pin 2, though: a current-limiting resistor suitable for a 3.3 V power supply will be inadequate to protect the LED when connected to 5 V. Remember to move the wire back to Pin 11 before continuing.
it blink. First, add the following line to create an infinite loop in the program: while True: Next, add the following lines to switch the pin on, wait 2 seconds, and then switch it off again before waiting another 2 seconds. Make sure each line starts with four spaces, to signify that it is part of the infinite while loop: GPIO.output(11, True) time.sleep(2) GPIO.output(11, False) time.sleep(2) The finished program should look like this (see Figure 12-4): import RPi.GPIO as GPIO import time GPIO.
with one or more inputs. In the following example, you’ll see how to connect a push-button switch to another pin on the GPIO port and read its status in Python. As with the earlier LED output example, this input example makes use of the Python GPIO library. Assuming that you have this library installed, you can begin to build the circuit. (If you haven’t installed the Python GPIO library yet, skip back a few pages and follow the installation instructions.
result, the circuit will act as though the button is being pressed even when it isn’t, and may fail to detect the button being pressed even when it is. Open a new Python file, either in a text editor or using one of the Python integrated development environments (IDEs) available on the Raspberry Pi. To begin, you will need to import the same GPIO library as in the previous GPIO output example: import RPi.
By extending the code to look for multiple push-buttons, each on an individual GPIO pin, you could even create a simple fourbutton game controller. For example, you could combine the preceding code with the Raspberry Snake game from Chapter 11, “An Introduction to Python”, to turn the Raspberry Pi into a simple games console. You can also combine both input and output examples into a single program, which waits for the button to be pushed and then turns on the LED by sending the output pin high.
This, among other reasons, is why the Raspberry Pi itself is built on a printed circuit board (PCB) rather than a breadboard— although the breadboard method was certainly used in the early days of prototyping the device. It’s possible to print and etch your own PCBs at home, but there is a simpler intermediate step you can take: using stripboard to create permanent stand-alone circuits. At first glance, stripboard looks similar to breadboard, because its surface is covered in small holes at 2.54 mm spacing.
Stripboard is extremely easy to use, which makes it a great stepping-stone to custom circuit board design and manufacturing. However, you should be aware of the following before you buy stripboard: • There are different types of stripboard. Some stripboards have copper tracks on the underside, which go all the way across a row or down a column, while other stripboards are split into two separate rows with a gap in the middle like a breadboard.
you’ll see plenty of evidence of this. All the larger components are connected using what’s called through-hole soldering, where the components’ leads are passed through holes in the printed circuit board and then soldered into place. Smaller components are attached via surface-mount soldering. Solder isn’t pure metal—it also contains a substance called flux, which is designed to etch away any tarnish on the surfaces to be soldered in order to ensure as clean a join as possible.
much onto the iron: not only is this a waste of solder, but it can cause excess solder to fall onto the work area. 2. Wipe the tip of the iron onto the sponge. If it hisses and spits, the sponge is too wet; allow it to cool, then remove it from the stand and wring it out. 3. Keep wiping the tip of the iron until it is coated in a silver layer of solder (see Figure 12-10). If necessary, apply more solder to the tip.
4. As the solder flows, you’ll see it drawn down into the hole in the board. This is an indication that the area is hot enough for a good solder join. If the solder floats, it indicates that the area is not yet hot enough. 5. Remove the solder from the join first, followed by the iron. (If you remove the iron first, the solder will harden and leave your spool of solder stuck to the contact!) If all went well, you’ll be left with a solid solder join that will last for many years.
Chapter 13: Add-on Boards Although you can to use the Raspberry Pi’s general-purpose input-output (GPIO) header directly, as you learned in Chapter 12, “Hardware Hacking”, a much better idea is to use a specialist prototyping board. Prototyping boards are add-on boards designed to sit between your project and the Raspberry Pi, and range from the relatively simple—such as Ciseco’s Slice of Pi— to the complex and powerful Gertboard.
specialised male-to-female jumper leads. The Slice of Pi also offers a small amount of protection for the Pi. The use of female headers means it’s harder to accidentally short-circuit two pins, and the spacing of the headers—with the eight general-purpose pins brought to one header and the other specialised pins brought to another—makes wiring mistakes less likely.
Table 13.1 Slice of Pi GPIO Translations Physical Pin Number Official Designation Slice of Pi Label 7 General Purpose Clock (or GPIO Pin 4) GP7 11 GPIO Pin 17 GP0 12 GPIO Pin 18 GP1 13 GPIO Pin 21 GP2 15 GPIO Pin 22 GP3 16 GPIO Pin 23 GP4 18 GPIO Pin 24 GP5 22 GPIO Pin 25 GP6 The Slice of Pi is available from Ciseco’s web shop at http://shop.ciseco.co.uk/slice-of-pi/.
The design and layout of the Prototyping Pi Plate will be familiar to anyone who has used an Arduino microcontroller. An add-on board with the same footprint as the target device, designed to connect to on-board headers and sit above the surface of the original board is a common sight in the Arduino world, where such add-on boards are known as shields. The idea for the Prototyping Pi Plate, in fact, comes from Adafruit’s self-designed Protoshield add-on for the Arduino.
Perhaps the biggest reason for choosing a Pi Plate over the Slice of Pi is its clever design. Once connected to the GPIO header on the Pi, there is little reason to remove it unless you need access to the DSI or MIPI CSI-2 camera connectors. Because it only increases the height of the Pi, rather than the width or length, and because it includes the screw terminals for side-on access to GPIO pins, it’s also compatible with a surprising number of Raspberry Pi cases (see Figure 13-6).
Fen Logic Gertboard Properly termed the Raspberry Pi I/O Extension, the Gertboard (shown in Figure 13-7) is named for its inventor Gert van Loo. An employee of Broadcom and a member of the team that designed the BCM2835 SoC processor at the heart of the Raspberry Pi, van Loo created the Gertboard as a way of unlocking some of the power of the chip hidden by the Pi’s overall design and providing a powerful and versatile platform for electronic tinkering.
Perhaps the most important feature of the Gertboard is the protection it offers to the Pi. Using a 3.3 V regulator, the Gertboard is designed to prevent the Pi’s GPIO port from receiving voltages it cannot handle. Like the Slice of Pi, it also attempts to restrict access to the six pins labelled Do Not Connect as well as the 3.3 V and 5 V pins to help prevent accidental shorting.
For sensing or feedback projects, the Gertboard’s ADC and DAC components are handy additions. Unlike the GPIO pins on the Pi itself, which can only receive and send digital signals, the Gertboard includes two ADC and two DAC connections. The ADC pins, located on the upper-left of the Gertboard, allow analogue components to be converted into digital signals compatible with the Pi.
Part IV: Appendixes Appendix A: Python Recipes Appendix B: HDMI Display Modes
Appendix A: Python Recipes The following recipes provide the program code for Example 3 and Example 4 in Chapter 11, “An Introduction to Python”, and a sample solution for the combined input-output program suggested in Chapter 12, “Hardware Hacking”. Each recipe is also available for download from the Raspberry Pi User Guide website at http://www.wiley.com/go/raspberrypiuserguide.
if direction == ‘left’: snakePosition[0] -= 20 if direction == ‘up’: snakePosition[1] -= 20 if direction == ‘down’: snakePosition[1] += 20 snakeSegments.insert(0,list(snakePosition)) if snakePosition[0] == raspberryPosition[0] and snakePosition[1] == raspberryPosition[1]: raspberrySpawned = 0 else: snakeSegments.pop() if raspberrySpawned == 0: x = random.randrange(1,32) y = random.randrange(1,24) raspberryPosition = [int(x*20),int(y*20)] raspberrySpawned = 1 playSurface.
names = [] while True: read_buffer += s.recv(1024) lines = read_buffer.split(‘\r\n’) read_buffer = lines.pop(); for line in lines: response = line.rstrip().split(‘ ‘, 3) response_code = response[1] if response_code == RPL_NAMREPLY: names_list = response[3].split(‘:’)[1] names += names_list.split(‘ ‘) if response_code == RPL_ENDOFNAMES: print ‘\r\nUsers in %(channel)s:’ % irc for name in names: print name names = [] time.sleep(irc[‘namesinterval’]) s.
Appendix B: HDMI Display Modes You can use the values in Table B-1 and Table B-2 with the hdmi_mode option in config.txt to alter the HDMI video output stream. For more information, see Chapter 6, “Configuring the Raspberry Pi”.
52 576p 200Hz 53 576p 200Hz (16:9 aspect ratio) 54 576i 200Hz 55 576i 200Hz (16:9 aspect ratio) 56 480p 24Hz0 57 480p 24Hz0 (16:9 aspect ratio) 58 480i 240Hz 59 480i 240Hz (16:9 aspect ratio) Table B-2 HDMI Group 2 (DMT) Value Description 1 640×350 85Hz 2 640×400 85Hz 3 720×400 85Hz 4 640×480 60Hz 5 640×480 72Hz 6 640×480 75Hz 7 640×480 85Hz 8 800×600 56Hz 9 800×600 60Hz 10 800×600 72Hz 11 800×600 75Hz 12 800×600 85Hz 13 800×600 120Hz 14 848×480 60Hz 15 1024×768
51 1600×1200 60Hz 52 1600×1200 65Hz 53 1600×1200 70Hz 54 1600×1200 75Hz 55 1600×1200 85Hz 56 1600×1200 120Hz (Reduced blanking) 57 1680×1050 (Reduced blanking) 58 1680×1050 60Hz 59 1680×1050 75Hz 60 1680×1050 85Hz 61 1680×1050 120Hz (Reduced blanking) 62 1792×1344 60Hz 63 1792×1344 75Hz 64 1792×1344 120Hz (Reduced blanking) 65 1856×1392 60Hz 66 1856×1392 75Hz 67 1856×1392 120Hz (Reduced blanking) 68 1920×1200 (Reduced blanking) 69 1920×1200 60Hz 70 1920×1200 75Hz 71