PC/CP320 Physical Computing
Raspberry Pi GPIO Introduction
Objectives
- To introduce the Raspberry Pi
- To become familiar with Raspberry Pi GPIO pins and
numbering
- To learn shell commands for interacting with Raspberry
Pi GPIO pins
Preparation
Equipment
- Raspberry Pi
- USB keyboard and mouse
- VGA monitor and HDMI-to-VGA adapter
- digital multimeter
Procedure
|
The Rapsberry Pi GPIO pins can easily be damaged with
improper handling. For this lab, you will not be
connecting
anything other than a meter to the GPIO pins.
|
-
Raspberry Pi Connections
DON'T APPLY POWER UNTIL EVERYTHING IS
CONNECTED PROPERLY!
Connect the USB keyboard and mouse and the wifi dongle to the
Raspberry Pi.
- Connect the monitor using the
HDMI-to-VGA adapter.
- Insert the micro-SD card, and plug the USB power connector
into the board.
- When you plug the adapter into the wall, the Pi should
boot up. (The switch in the cable allows you to turn off power
without having to unplug.)
-
Early on you should see a rainbow screen, and it should
end with a command prompt.
Show successfully booted Raspberry Pi to the lab
instructor.
- The default login to the pi is "pi", and the default password
is "raspberry". For now, don't change these!
-
GUI and wifi
When the pi is booted and you are logged in, type
startx
to launch the graphical user interface.
- From the menu, you should be able to select wifi, and
be able to connect to eduroam.
By default, the pi won't remember your eduroam password for
security.
(Alternatively, you can click on the the wifi icon.)
You should now be able to open a browser and access this web page.
Show this to the lab
instructor.
- You can now open a terminal so that you can leave the GUI open
and still work at the command line.
If you can't connect to eduroam, it may be that the router is too busy.
You can go ahead and do the rest of the lab; just use your laptop or
phone to read the instructions.
-
Here are some common commands for linux. Note that the cursor up
and down keys take you through a history of previously used commands.
Common linux commands
|
Command
|
Description
|
Example
|
ls
|
list files in directory
|
ls
*.py
|
sudo
|
execute program as superuser
|
sudo
python3 test.py
|
shutdown
|
shutdown computer properly
|
sudo shutdown
-h now
|
-
Identifying GPIO pins
Identify pins GPIO17 and GPIO18 according to the Broadcom
numbering scheme. Which pins are they in the board
numbering scheme?
Show identified GPIO pins to the lab
instructor.
-
Using the shell to control GPIO pins
Accessing GPIO pins from user space
Set up pin GPIO18 for output, and use the voltmeter to show that
you can set it HIGH and LOW.
-
Set up pin GPIO17 for input, and connect it to GPIO18.
Change the state of pin GPIO18 and see that that is detectable by
GPIO17.
Demonstrate outputting to and inputtting from GPIO pins
to the lab
instructor.
- When you are done, shut down using
sudo shutdown -h now
When shutdown is complete, you can disconnect power, and put
everything away. Be sure to reconnect the display, keyboard, and
mouse to the computer.
Wilfrid Laurier University
© 2019 Wilfrid Laurier University