List of Figures

Chapter 1. Meet Raspberry Pi

Figure 1.1. The Raspberry Pi provides an excellent platform for learning to program in Python. It includes many input and output ports to give you flexibility in how you connect it. As you would with a desktop computer, you need to connect a keyboard, mouse, monitor, and power cable before you can start using your Pi.

Figure 1.2. A case protects your Raspberry Pi from damage while making it easy to access the ports. Some people use a case to give their Pi a unique personality. You can purchase a case or, better yet, make your own. Plastic cases are the most common, but these pictures show examples of cases made from paper, plastic, and aluminum. You could even try using LEGOs to make one.

Figure 1.3. The Raspberry Pi’s system on a chip (SoC) contains its computing and graphics processing power and working memory. The Pi uses the ARM11 microprocessor as its CPU and the VideoCore IV for its GPU. The ARM11 microprocessor is found in handheld electronics such as smart phones and gaming systems. The SoC in the Raspberry Pi 2 Model B comes with 1 GB of RAM.

Figure 1.4. The Raspberry Pi 2 Model B has four USB ports. They’re on the board in two sets of two, side by side. The USB ports are useful for connecting a keyboard and mouse to your Pi. A USB hub can also be plugged in to allow for even more peripherals.

Figure 1.5. You need a USB keyboard to type and enter commands on your Raspberry Pi. The keyboard plugs into one of the four available USB ports on the Raspberry Pi 2 Model B.

Figure 1.6. An SD memory card provides the storage memory used by the Raspberry Pi to hold all the software and files, including the operating system. Raspberry Pi kits come with an SD memory card preloaded with the software needed to start up your Pi. The two left images show the location of the SD memory card slot on the underside of the Pi board. The right image shows an SD memory card inserted into the SD card slot.

Figure 1.7. The HDMI port on the Raspberry Pi provides a high-definition audio and video signal that can be connected to a TV or monitor. Use an HDMI cable to connect your Pi to your TV or monitor. Depending on the connectors available on the TV or monitor, you may need an adapter.

Figure 1.8. HDMI and DVI are common types of video input ports found on modern TVs and monitors. It’s easiest to connect a Raspberry Pi to a TV or monitor with an HDMI port. HDMI provides a highdefinition picture and doesn’t require any adapters or converters—only an HDMI cable, which is included in many Pi kits. The DVI port requires a special adapter to connect with a Pi.

Figure 1.9. A Raspberry Pi can be connected to a TV or monitor using an HDMI cable. Connect the cable from the Pi’s HDMI port to the TV’s or monitor’s HDMI input. In addition to video, the HDMI cable also contains the Pi’s audio output, which can be played through the TV’s or monitor’s speakers.

Figure 1.10. The Raspberry Pi can be connected to a TV or monitor with a DVI port using an HDMI-to-DVI adapter and an HDMI cable. One end of the HDMI cable plugs into the Pi’s HDMI port. The other is connected to the adapter, and the adapter is connected to the TV or monitor. Adapters are available through online retailers or local computer stores.

Figure 1.11. The Raspberry Pi requires a microUSB power supply that provides at least 1.2 A of electric current. If you plan to use all the USB ports on your Pi, you may want one that provides 2 A or more of electric current. The recommended voltage is 5 volts (V), but the Pi can operate at voltages ranging from 4.8 to 5.2 V. If you have a power supply you want to use with your Pi, check its output voltage and current, which are listed on the charger in small print. In this example, the charger has an output of 5.1 V and 2.5 A of current, making it a suitable power supply for a Pi. Using the incorrect voltage or insufficient current can damage or destroy your Pi, so check carefully.

Figure 1.12. Example setup of a Raspberry Pi with peripherals connected and SD card inserted. A keyboard and mouse are connected to the Pi’s two available USB ports. A microUSB power supply is plugged into the Pi; the other end is lying on the desk, ready to be plugged into the wall. An HDMI cable is connected from the Pi’s HDMI port to the back of the monitor. The Ethernet port has an Ethernet cable plugged into it from a router (not shown).

Figure 1.13. The NOOBS selection menu allows you to choose the OS you want to install on your SD card and use with your Raspberry Pi. This menu appears the first time you start up your Pi.

Figure 1.14. When your Pi boots up for the first time, you’ll see the Raspberry Pi configuration menu. This menu makes it easier to set up your Pi by allowing you to change settings such as the time zone and keyboard layout. The menu also has the option to set your Pi to always boot to the Raspbian desktop environment.

Figure 1.15. Example screen images of a command-line mode (top) and a GUI mode (bottom) for a Raspberry Pi running the Raspbian OS. The command-line mode is text-based: you enter instructions at the prompt. The GUI is pretty much the same as a Windows or Mac interface, with windows, icons, and menus that you interact with using a mouse pointer.

Figure 1.16. A view of the Raspbian desktop after your Raspberry Pi boots up. The desktop is similar to the desktop in Microsoft Windows or Apple Mac OS X. Don’t worry if your desktop is different from this one. Depending on when you bought your Pi, you may have received an SD card with an older or newer version of Raspbian.

Figure 1.17. If you didn’t set up your Pi to boot to the Raspbian desktop, the command-line mode will be displayed when your Raspberry Pi boots up. It will ask you for your login name and password.

Figure 1.18. The Raspbian application menu opens when you click the Menu button in the top-left corner of the desktop. You can open an application by moving your mouse over the categories listed on the menu and then clicking the application.

Figure 1.19. File Manager in Raspbian allows you to manage files as you do in Windows Explorer or Mac Finder. You access File Manager using the folder icon in the upper-left corner of the desktop. This is a view of a Pi with a lot of files stored in the /home/pi folder.

Figure 1.20. IDLE is a development environment that makes it easier to write Python programs. This is the IDLE Python Shell that you can use to enter Python commands or instructions one at a time.

Figure 1.21. You can access the Pi Store from the icon on your Raspbian desktop. The store allows you to browse and download apps and content including games, tutorials, and digital magazines. You’ll find free and fee-based content, organized into five categories: Games, Apps, Tutorials, Dev Tools, and Media.

Chapter 2. Exploring Python

Figure 2.1. The Python 3 icon on your Raspberry Pi opens an interactive programming shell for Python 3.x.

Figure 2.2. The Python 3 application under Menu > Programming on the Raspberry Pi desktop opens IDLE to the Python Shell for Python 3.x.

Figure 2.3. The menu at your favorite burger restaurant

Figure 2.4. Use the + symbol to add numbers in Python.

Figure 2.5. The distance from the Earth to the Sun is approximately 149,600,000 km. The Raspberry Pi is 85.6 mm in length.

Figure 2.6. The menu at your pizza restaurant

Figure 2.7. A variable stores information and can be created and assigned a value. The equals sign is used as an operator (also known as the assignment operator) between the name of the variable on the left and the value assigned to it on the right.

Figure 2.8. When a variable is created, it’s stored in your Raspberry Pi’s memory. You can change the value of a variable at any time. Using the print function, you can display the variable’s value on the screen.

Figure 2.9. Python follows the order of operations used in mathematics. You may know it as BOMDAS or PEMDAS: Brackets (or Parentheses), Orders (or Exponents), Multiplication and Division, and finally Addition and Subtraction.

Figure 2.10. The print function in Python displays text on the screen. The string inside the parentheses must be enclosed in single or double quotation marks.

Figure 2.11. The Python print function can display text on the screen repeatedly if you use it with a string and the multiplication operator (*).

Figure 2.12. Remember to place quotation marks at the beginning and end of your strings. If you forget to close your quotation mark, Python will display an error.

Figure 2.13. The top window is the IDLE Python Shell. The bottom window is the IDLE text editor that can be used to create and edit Python programs. You can open the IDLE text editor using Ctrl-N or by selecting File > New Window from the IDLE Python Shell.

Figure 2.14. IDLE provides a text editor that helps you write Python programs. The editor highlights words to help you compose your programs and identify errors. This program prints a message to the screen.

Figure 2.15. Save programs in IDLE using the File > Save menu selection or by pressing Ctrl-S. The default save location is /home/pi. When the file is saved, it has .py appended to the end of its name, signifying that it’s a Python program.

Figure 2.16. You can run programs from the IDLE text editor. Running a program in IDLE displays the results of the program in the Python Shell. This shows the output of your first program by displaying a message.

Figure 2.17. Leafpad is a text editor that comes with Raspbian. You can access Leafpad from the Accessories menu.

Figure 2.18. Saving a file in Leafpad lets you choose the folder to save to and enter a filename. The Save window works similarly to how you might save a file in Microsoft Word.

Figure 2.19. Viewing the contents of folders using File Manager

Figure 2.20. Try using the print function and strings to make a screen full of 1s and 0s.

Figure 2.21. This challenge uses the print function and a string named brick to create a brick wall pattern on the screen.

Chapter 3. Silly Sentence Generator 3000: creating interactive programs

Figure 3.1. Silly Sentence Generator 3000 asks the user to enter their name and some words, and then it creates a silly sentence from those words.

Figure 3.2. An interactive game lets you put in information, and then it creates an output.

Figure 3.3. Select Menu-->Programming-->Python 3 to open the Python Shell on your Raspberry Pi.

Figure 3.4. The Python Shell

Figure 3.5. The IDLE text editor is where you can type in your Python program. You can also edit, save, and run programs using the menu options.

Figure 3.6. Save your file as SillySentence. This stores the file on your Raspberry Pi in your /home/pi folder so you can run the program and make changes to it.

Figure 3.7. The first three lines of your program use the print function to create a welcome message for the Silly Sentence Generator 3000 program.

Figure 3.8. Running the program SillySentence.py displays a welcome message on the screen.

Figure 3.9. The input function displays a prompt to the user. The prompt “Please enter your name:” tells the user what you want them to type in or enter. In this case, you’re asking for their name.

Figure 3.10. silly-sentence is created by joining a set of strings. The strings are a combination of strings you enter with quotation marks around them and strings collected from the game player that are stored in variables. The parentheses are needed because the code is too long to fit on a single line.

Figure 3.11. If you forget to close a set of quotation marks around a string, you’ll receive an error from Python when you try to run your program. Python will highlight in red the line with the error. Check each of the strings to find and fix the error.

Figure 3.12. A common mistake in programming is to misspell the name of a variable or use incorrect capitalization. The error displayed says there is a problem on line 25 of the program. The type of error is NameError: name 'adjectve1 ' is not defined.

Figure 3.13. Silly Sentence Generator 3000 is a fun program that shows how programs can collect information from users, interact with them, and provide a more personal feel.

Figure 3.14. The Silly Sentence Generator 3000 makes some absurd sentences based on words you enter.

Figure 3.15. Minecraft Pi is a slimmed-down, free version of Minecraft that’s based on Minecraft Pocket Edition. It’s limited compared to the full version but still oodles of fun!

Figure 3.16. The Minecraft Pi main screen allows you to start a singleplayer game or join a multiplayer game. The multiplayer option lets you connect to someone else’s world, but you’ll need to be on the same network.

Figure 3.17. Each Minecraft world is made of blocks but is different. You might find yourself in a forest or in a desert. The bottom of the screen shows you the items in your inventory. Use the mouse scroll wheel to select different items, or press the numbers 1–9 on your keyboard.

Figure 3.18. The subliminal-message challenge is about hiding a secret message in a bunch of characters on the screen. Can you see the hidden message?

Chapter 4. Norwegian Blue parrot game: adding logic to programs

Figure 4.1. The Norwegian Blue parrot has beautiful plumage and makes a great subject for a guessing game.

Figure 4.2. The game logic can be expressed in words. The question marks symbolize when the game needs logic to make a decision. This diagram also shows what code needs to be repeated because the player gets five guesses. Each decision has a simple True/False or Yes/No answer.

Figure 4.3. The Norwegian Blue Guessing Game is about trying to guess the age of a bird in a pet shop.

Figure 4.4. Click the Python 3 icon to open IDLE’s Python 3 Shell on your Raspberry Pi.

Figure 4.5. Once you’ve saved the file, the top of the window displays the filename and the location where the file is stored on your Raspberry Pi (/home/pi/NorwegianBlue.py). The cursor location is always shown at the bottom right of the window.

Figure 4.6. Python will display an error if you forget starting or ending quotation marks. The line with the error will be highlighted in your program. Fix the program by adding the missing quotation marks, and then save and run the program.

Figure 4.7. A string literal must start and end with a set of triple quotation marks. If you forget, Python will tell you that you have a syntax error. Add the missing triple quotes to fix the error.

Figure 4.8. The input function gathers text typed in by the user; then the text is stored in a variable as a string data type. You take the value of the variable (“5”), convert it to an integer (5), and store it as the variable.

Figure 4.9. On the left is the logic you want to create. On the right is your code. So far, you’ve welcomed the user and given them the game instructions. You’ve also added code to collect their guess.

Figure 4.10. The if statement can control the flow of your programs. This example shows how an if statement can be used to display one message if guess is equal to the parrot’s age or a different message if they aren’t equal.

Figure 4.11. The logic you want to create is shown in the code. You use the if statement to check whether the player’s guess is correct.

Figure 4.12. A missing colon at the end of an if statement will create a syntax error. Python highlights where the error is located. Add a colon at the end of the line to fix the problem.

Figure 4.13. Think of the logic you’re trying to create, and then translate it into your code. When you need to repeat something, you can use a while loop. When you need to check whether something is True or False, you can use an if statement.

Figure 4.14. You can use a while loop to repeatedly perform a task. Code that is part of the loop is indented four spaces. In this case, this while loop displays the numbers from 0 to 99; when completed, it prints the message, “I finished counting!” Typically, the condition should be such that code in the loop can make it False and thus end the loop.

Figure 4.15. To randomly select a number, you need to import the random library and use the randint function to select a random integer between 1 and 20.

Figure 4.16. The Scratch interface is divided into an area for sprites to move around and a script area. You can create programs for your sprite by dragging blocks and connecting them in the script area.

Chapter 5. Raspi’s Cave Adventure

Figure 5.1. Raspi’s Cave Adventure requires the player to make decisions about which way to go. Based on their choices, the player will meet different fates.

Figure 5.2. This map of the cave system shows that Raspi will need to make many choices. If he makes the wrong ones, it’s game over! But if he makes the correct choices, he’ll find the legendary treasure!

Figure 5.3. The flow diagram for Raspi’s Cave Adventure shows the various decisions the player can make and their outcomes. It’s a map of the logic of the game, and it can guide you as you program that logic.

Figure 5.4. Flow diagrams are ways to visually show the logic of a program. They represent decisions, choices, and activities using diamonds, arrows, and boxes. This example shows a flow diagram for a program that turns on a light if a button is pressed.

Figure 5.5. The if statement can come in many flavors. This is an if statement with two elifs and an else. It creates logic in the code that can do many different things depending on the user’s input. In this case, you’re having a player guess the age of a parrot. The program will tell them if their guess is too low, too high, correct, or invalid.

Figure 5.6. The left cave has a stream inside it, and the user has three choices of what to do next. In the code, you create an if statement followed by two elif statements to cover each of the options. The else statement is used to control what happens if the user inputs something other than one of the three choices.

Figure 5.7. Functions simplify your code and can reduce repetition. Use the def keyword to create a new function, and indent the function code under it. If you need a function to return a value, include a return statement in the function.

Figure 5.8. The right cave consists of a series of decisions. One wrong move, and certain death awaits Raspi. If the user makes the right choices, Raspi will find the treasure. The code uses if/elif/else statements and functions. See the code files for chapter 5 for examples of the functions.

Figure 5.9. if statements can be nested within other if statements. In this case, the user is only prompted to guess the password if they first guess the secret name correctly. Python uses indentation to figure out what statements belong together and which if statements are nested within other ones.

Figure 5.10. Highlighting by IDLE when there is invalid syntax due to a missing colon (:) at the end of an if statement

Figure 5.11. Highlighting by IDLE when there is only one equals sign

Figure 5.12. The Pi’s monitor is a live stream from an aquarium. Check out that shark! By using Livestreamer and OMXPlayer, you can stream live video from exotic places, like water holes in Africa and the International Space Station.

Chapter 6. Blinky Pi

Figure 6.1. The Blinky Pi project requires parts that are commonly found in Raspberry Pi starter kits or that can be purchased online.

Figure 6.2. The Raspberry Pi 2 Model B has a set of pins arranged along the edge and corner of the Pi board.

Figure 6.3. The Raspberry Pi B+ has 40 pins. They do different things: some provide 5 volts or 3.3 volts, some are ground pins (0 volts), and many of them are input and output pins that you can program.

Figure 6.4. To easily create projects using your Pi’s GPIO pins, you can connect the Pi to a breadboard using a ribbon cable and breakout board. The parts shown are examples of the ones commonly found in many Raspberry Pi kits.

Figure 6.5. Carefully line up the breakout board, and then press it firmly into the breadboard. The two rows of pins on the breakout board should straddle the center gap.

Figure 6.6. Connect one end of the ribbon cable to the breakout board. Connect the other end to your Raspberry Pi.

Figure 6.7. Breadboards have internal connections. You need to know about them in order to build circuits. Rows of pins are connected horizontally, but not across the gap in the middle. Long rails called power buses run vertically along the sides of the board.

Figure 6.8. To find a specific hole on a breadboard, use the row and column labels. This is a close-up of a breadboard, showing how you can find the location of hole 25c (we’ll refer to the hole as BB25c, where BB stands for breadboard).

Figure 6.9. Circuit diagram for the blinking LED project

Figure 6.10. LED circuit built on the breadboard. You’re using GPIO pin 21 as the power source. The light won’t turn on until you program the voltage to come out of the pin.

Figure 6.11. The breakout board has labels that correspond to the pins on your Pi. To connect a wire to GP16, you plug it into the breadboard in the hole labelled BB18f or BB18j.

Figure 6.12. LEDs have two legs (wires) coming out of them. The longer leg is called the anode and connects to the positive side of the circuit. The shorter one is called the cathode and connects to the negative side of a circuit.

Figure 6.13. The value of a resistor is determined by its colored bands. See the sidebar “Resistor color codes” for a chart; there are also many online color-code charts.

Figure 6.14. Circuit diagram for three LEDs: red, green, and blue. You’ll use 180 ohm resistors like before. They will all be controlled by different GPIO pins. Red will use 21, green will use 22, and blue will be connected to pin 23. You could use any of the 26 different GPIO pins.

Figure 6.15. The three-LED circuit is built on the breadboard. Each LED and its corresponding resistor are placed in a row together. This example uses rows 25, 27, and 29.

Chapter 7. Light Up Guessing Game

Figure 7.1. The Light Up Guessing Game uses a red, green, blue (RGB) LED. An RGB LED can produce many different colors because it has three LEDs (colored red, green, and blue) packed inside it.

Figure 7.2. The Light Up Guessing Game responds to the user after each guess. Lights on the breadboard light up to let the player know if their guess is too high or too low.

Figure 7.3. The Pi, breakout board, and breadboard setup. And you thought your desk was messy before!

Figure 7.4. Circuit diagram for the Light Up Guessing Game project

Figure 7.5. The RGB LED circuit you’re building on the breadboard uses GPIO pins 12, 16, and 21 to power the LEDs. The light won’t turn on until you program the voltage to come out of the pins.

Figure 7.6. The RGB LED has lots of legs! The longest leg is the ground. The other ones are for red, green, and blue. This applies to what is called a common cathode RGB LED, which is what comes in Pi kits and what you’ll find most commonly at electronics suppliers.

Figure 7.7. Bend the legs of the RGB LED, and insert it into the breadboard at BB22h, BB24h, BB26h, and BB28h. The longest leg goes into hole BB24h.

Figure 7.8. The jumpers connect the GPIO pins from your Pi to the RGB LED. If you have an earlier model Pi, you can use other GPIO pins. Just remember which ones you’re using, and use these numbers when you program the Pi to turn the GPIO pins on and off.

Figure 7.9. The colored bands on a resistor tell you how much resistance the resistor has. For this project, you want a brown (1), grey (8), brown (×10) resistor, or 18 × 10 = 180 ohm resistor. Don’t have one? Any resistor between about 100 and 300 ohms should work well.

Figure 7.10. Add your resistors! Make sure you push them down into the breadboard holes. If you don’t like them sticking up so high, you can trim the ends using wire cutters.

Figure 7.11. The jumper is added to connect the ground of the RGB LED to the ground of the Raspberry Pi. The jumper can connect anywhere along the ground rail (it usually has a blue stripe running next to it).

Figure 7.12. Flow diagram showing how the guessing game should work. Notice how you’re blinking LEDs if the guess is too low, too high, or correct. You also give the player the choice of whether they’d like to play again.

Figure 7.13. The program starts by importing the Python libraries you’ll need to use, setting up your Pi’s GPIO pins for lighting up the LEDs, and defining the functions you’ll need.

Figure 7.14. After displaying the game title and instructions, you need to define variables to store important game information, including a random number the player is trying to guess. The main loop in the game is repeated to allow the user to make five guesses; it also blinks the lights.

Figure 7.15. The Play Again Loop is wrapped around the Guessing Game Loop. After the player has exhausted their guesses or guessed the number correctly, they’re asked if they want to play again. Depending on their answer, the game will either start over or end.

Chapter 8. DJ Raspi

Figure 8.1. The DJ Raspi project requires several different parts to turn your Pi into a music player. The length and color of the jumper wires don’t matter.

Figure 8.2. When you install Raspbian on your Pi, it comes with Scratch, which has a number of sound files including vocals, sound effects, animal sounds, and drum beats.

Figure 8.3. The mini pushbutton makes a nice clicking sound when you press the black button in the middle. Pressing it acts like closing a switch to complete a circuit.

Figure 8.4. The circuit diagram for the first button in the DJ Raspi project shows how electricity will flow through the circuit. The button is a switch that allows electricity to flow to GP06 and ground (-) when it’s pressed or closed.

Figure 8.5. The mini pushbutton will have 3.3 volts connected to it from the positive power rail. When the button is pressed, power flows through the button and splits. Some electrical current goes to GP06 (GPIO pin 6), and the rest goes through the resistor and then to the negative power bus (-).

Figure 8.6. In a button, the legs are connected along the top and are separately connected along the bottom. When the button is pressed, the top and bottom are connected by a small metal bar.

Figure 8.7. Align the pushbutton with the breadboard holes, and then press it down into the breadboard. Make sure you press it so the button legs are down into the breadboard holes and make a good connection. If you accidentally bend the legs, don’t worry! Just bend them back and try again.

Figure 8.8. The jumper connects power (3.3 volts) to the bottom of the button.

Figure 8.9. Add the resistor. Make sure its ends are pushed down into the breadboard holes.

Figure 8.10. The jumper connects the top of the button to GP06. Later, you’ll set your Pi to listen for electrical input on this GPIO pin.

Figure 8.11. Add the second pushbutton just below the first one. The wiring is the same, but you’ll connect it to GP19 (GPIO pin 19). Any available GPIO pin will work, but remember that your code will have to reflect the GPIO pins you select.

Figure 8.12. A flow diagram showing how the DJ Raspi program should work. The program must gather a list of sounds at the beginning and then check whether the buttons are pressed. The buttons will be checked over and over again.

Figure 8.13. The first step is to set up the buttons as inputs. This will mean your Pi is ready to check whether it’s detecting any voltage coming in, which will happen when a button is pressed.

Figure 8.14. The next step of the DJ Raspi program gets a list of sound files. Later, you’ll add the part that uses the button to trigger playing random sounds from the lists.

Figure 8.15. You make lists by using square brackets to enclose a set of things. Each thing in the list should be separated with a comma. Python will even let you make lists that combine different types of data, like strings and integers.

Figure 8.16. Sets of things can be stored in lists. You can retrieve items from the list using the index, which represents the position of an item in the list. The index of a list starts at 0.

Figure 8.17. The main part of the DJ Raspi program is the loop to check the buttons. You’ll use a while loop to check the buttons over and over again. If one of them is pressed, you’ll tell Raspbian to play a random sound using OMXPlayer.

Figure 8.18. There are two places where you can create functions so you can reuse code. One function creates a list of sound files, and the other function plays a random sound when a button is pressed.

Appendix A. Raspberry Pi troubleshooting

Figure A.1. Clean up (or reformat) your SD card using the SDFormatter software available from the SD Association website. In SDFormatter, select the drive letter for your SD card, and click Format to have your card wiped clean. This process means you’re starting over—you lose anything saved or installed on your Pi—but sometimes that is the only option.

Appendix B. Raspberry Pi ports and legacy boards

Figure B.1. The Raspberry Pi 2 Model B has many different input and output ports that allow you to connect a keyboard or mouse, monitor, and even high-definition cameras.

Figure B.2. The network connection icon is located near the top-right corner of the Raspbian desktop. Clicking on it allows you to view nearby wireless networks.

Figure B.3. Enter the pre-shared key for the network and click OK to connect to it.

Figure B.4. The Raspberry Pi’s 3.5 mm audio/video port is used to connect headphones or speakers for playing sounds. It can also function as a low-quality video output, if you purchase a 3.5 mm-to-RCA composite video adapter.

Figure B.5. The Raspberry Pi camera module was created by the Raspberry Pi Foundation to take high-def digital photographs and video. The camera attaches to the Pi using a ribbon cable that connects to the Camera Serial Interface port. The camera module can be programmed using Python and used for nature photography or creating your own home-surveillance system.

Figure B.6. The Raspberry Pi camera can connect to the CSI port, which is located between the HDMI port and the 3.5 mm audio/video port. To connect a camera, you need to lift up the black connector, insert the ribbon cable (metal contact toward the HDMI port), and push down on the black connector again.

Figure B.7. The Ethernet port on the Raspberry Pi supports connecting a Pi to a home network. Connect an Ethernet cable from your Pi to your router or modem to access the internet. With your Pi connected to a network, you can remotely connect to the Pi from another computer using special programs such as SSH and VNC Server.

Figure B.8. Common types of video input ports found on TVs and monitors. A Raspberry Pi can connect to any one of these ports. Some ports (DVI, VGA, RCA [or composite], and component) require using special adapters or converters with a Pi.

Figure B.9. The Raspberry Pi can be connected to a TV or monitor using an RCA video cable. The cable connects from the Pi’s 3.5 mm audio/video port to the RCA video input port on the TV or monitor. Using the RCA connection produces a low-quality picture but can be a good option if you don’t have a TV or monitor that supports HDMI.

Figure B.10. The Raspberry Pi 1 Model B has been wildly popular. It has been used for a spectrum of applications from scientific research to art and education.

Figure B.11. The Raspberry Pi 1 Model B+ was a major revision of the Raspberry Pi 1 Model B. It increased the number of USB ports from two to four, added more pins for GPIO, and changed to a microSD memory card slot. The ports on the Raspberry Pi 1 Model B+ are the same as those on the Raspberry Pi 2 Model B.

Appendix C. Solutions to chapter challenges

Figure C.1. Make the cat dance in Scratch by dragging program blocks into the script area.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.168.172