Python All-in-One For Dummies
Book image
Explore Book Buy On Amazon
Before you can get going here, make sure you have your Raspberry Pi computer set up and running on your monitor, keyboard, and mouse. If not, go do that now The next few paragraphs are going to be lots more fun with a computer to work with!

The Raspberry Pi is the perfect platform to do physical computing with Python because it has a multiscreen environment, lots of RAM and storage to play with and all the tools to build fun projects.

A huge and powerful feature of the Raspberry Pi is the row of GPIO (general purpose input-output) pins along the top of the Raspberry Pi. It is a 40-pin header into which you can plug a large number of sensors and controllers to do amazing things to expand your Raspberry Pi.

GPIO pins on the Raspberry Pi

GPIO pins can be designated (using Python software) as input or output pins and used for many different purposes. There are two 5V power pins, two 3.3V power pins and a number of ground pins that have fixed uses.

Raspberry Pi GPIO pins The functions of the Raspberry Pi GPIO pins.

An GPIO pin output pin “outputs” a 1 or a 0 from the computer to the pin. Basically, A “1” is 3.3V and a “0” is 0V. You can think of them just as 1s and 0s.

GPIO Python libraries

There are a number of GPIO Python libraries that are usable for building projects. A good one to use is the gpiozero library that is installed on all Raspberry Pi desktop software releases. Check out the library documentation and installation instructions (if needed).

Now let’s jump into the “Hello World” physical computing project with our Raspberry Pi.

The hardware for “Hello World” on the Raspberry Pi

To do this project, you’ll need some hardware. Because these instructions involve using Grove connectors, let's get the two pieces of Grove hardware that you need for this project:
  • Pi2Grover: This converts the Raspberry Pi GPIO pin header to Grove connectors (ease of use and can’t reverse the power pins!). You can buy this either at shop.switchdoc.com or at Amazon.com. You can get $5.00 off the Pi2Grover board at shop.switchdoc.com by using the discount code PI2DUMMIES at checkout.

    Pi2Grover board The Pi2Grover board.
  • Grove blue LED: A Grove blue LED module including Grove cable. You can buy this on shop.switchdoc.com or on amazon.com.

    Grove blue LED The Grove blue LED.
Grove cable The Grove cable (included with the LED).

How to assemble the Raspberry Pi’s hardware

For a number of you readers, this will be the first time you have ever assembled a physical computer-based product. because of this, we’ll give you the step-by-step process:
  1. Identify the Pi2Grover board.
  2. Making sure you align the pins correctly gently press the Pi2Grover Board (Part A) onto the 40 pin GPIO connector on the Raspberry Pi.

    aligning Pi2Grover board Aligning the Pi2Grover board on the Raspberry Pi.
  3. Gently finish pushing the Pi2Grover (Part A) onto the Raspberry Pi GPIO pins, making sure the pins are aligned. There will be no pins showing on either end and make sure no pins on the Raspberry Pi are bent.

    installed Pi2Grover board The installed Pi2Grover board.
  4. Plug one end of the Grove cable into the Grove blue LED board.

    Grove cable A Grove cable plugged into the Grove blue LED board.
  5. If your blue LED is not plugged into the Grove blue LED board, then plug in the LED with the flat side aligned with the flat side of the outline on the board.

    Raspberry Pi LED algined on Raspberry Pi board The LED aligned with the outline on the board.
  6. Plug the other end of the Grove cable into the slot marked D12/D13 on the Pi2Grover board.You are now finished assembling the hardware. Now it’s time for the Python software.

    Hello World Python The completed “Hello World” project.

About This Article

This article is from the book:

About the book authors:

John Shovic, PhD, is a computer science faculty member at the University of Idaho specializing in robotics and artificial intelligence.

Alan Simpson is a web development professional who has published more than 100 articles and books on technology.

John Shovic, PhD, is a computer science faculty member at the University of Idaho specializing in robotics and artificial intelligence.

Alan Simpson is a web development professional who has published more than 100 articles and books on technology.

This article can be found in the category: