qwertylabs
QK / LESSONS · FOUNDATION 01

Raspberry Pi basics.

A true first session with a Raspberry Pi: set it up, find your way around, make folders, meet Terminal, save and run Python, then shut down safely.

Studio deck
01 · before you begin

What is on the table?

Today you are going to use the Raspberry Pi as a small desktop computer. Nothing is hidden or assumed.

Raspberry PiThe computer itself.
microSD cardIts storage. For this lesson, Raspberry Pi OS is already installed on it.
Monitor + HDMI cableSo you can see what the Pi is doing.
Keyboard + mouseYou will use both throughout this deck.
Correct Pi power supplyThis gets connected last.
This deckKeep it open on a second device if possible.
Before you touch anythingThe Pi should be switched off and disconnected from power. If your microSD card is not already prepared with Raspberry Pi OS, stop and ask your tutor.
02 · hardware tour

Meet the Raspberry Pi

Simplified Raspberry Pi board showing its main connectors
Your model may arrange the ports slightly differently. The names are what matter.

Find each part on the real board before moving on:

  • 40-pin GPIO header: two long rows of metal pins.
  • USB ports: keyboard and mouse can connect here.
  • Display connector: HDMI or micro HDMI, depending on model.
  • Power connector: USB-C on current full-size models.
  • microSD slot: usually underneath the board.
  • Camera connector: a thin ribbon-cable socket.
For nowDo not connect anything to the GPIO pins or camera connector. We are only identifying them.
03 · physical setup

Connect it in this order

  1. Make sure the Pi is not connected to power.
  2. Insert the prepared microSD card into the microSD slot. It only fits one way; do not force it.
  3. Connect the monitor to the Pi with the correct HDMI cable.
  4. Connect the keyboard to a USB port.
  5. Connect the mouse to a USB port. If your keyboard/mouse share one wireless USB receiver, connect that receiver instead.
  6. Turn the monitor on and choose the correct HDMI input if necessary.
  7. Last: connect the Raspberry Pi power supply.
What should happen?The Pi should start by itself and the monitor should show boot activity, then the Raspberry Pi desktop.
If the screen stays blankDo not pull wires at random. Check the monitor is on, the correct HDMI input is selected, and the HDMI cable is firmly connected. Then ask your tutor before changing anything else.
04 · first boot

Wait for the desktop

Starting a computer is called booting. Raspberry Pi OS is the software that starts and runs the Pi. Raspberry Pi OS is based on Linux.

  1. After connecting power, wait. The first boot can take a little longer than later boots.
  2. Do not press keys just because text or logos appear. Let the Pi finish.
  3. When you see a desktop with a taskbar/menu, move the mouse. The pointer should move.
  4. Press a letter key in a harmless place such as the search field only if your tutor asks you to test the keyboard.
If a setup wizard appearsStop here and tell your tutor. This reusable lesson assumes the studio Pi has already been configured.
05 · desktop

Find the three things we will use

Simplified Raspberry Pi desktop showing the Raspberry Pi menu, File Manager and Terminal

Your desktop may look a little different, but find these three things:

Raspberry Pi menu

The Raspberry Pi icon at the top-left. It opens the application menu.

File Manager

The folder icon. It lets you see and organise files and folders.

Terminal

The little command-window icon. We will explain it before you type anything.

New word: desktopThe graphical screen with icons, menus, windows and a mouse pointer. This is one way of controlling Linux.
06 · files + folders

Make your first project folder

First we will make a folder using the mouse. Later we will find the same folder using Terminal.

  1. Open File Manager by clicking the folder icon on the taskbar. If you cannot see it, open the Raspberry Pi menu → Accessories → File Manager.
  2. In File Manager, choose your Home folder. This is your personal storage area on the Pi.
  3. Move the pointer into an empty area of the file list and right-click.
  4. Choose New Folder.
  5. Type exactly pi-projects.
  6. Press Enter.
What should you see?A new folder named pi-projects in your Home folder. Double-click it once to prove it opens, then use the Back button to return Home.
If the folder is somewhere unexpectedDo not make another one. Use the Back or Home button in File Manager until you can see your Home folder, then move or recreate it with your tutor.
07 · terminal

What is Terminal?

Terminal is a window where you control the same computer by typing short commands instead of clicking icons.

  1. Click the Terminal icon on the taskbar. If you cannot see it: Raspberry Pi menu → Accessories → Terminal.
  2. A window opens. You will see a line ending in a symbol such as $. This is the prompt: the Pi is waiting for you.
  3. Click inside the Terminal window once. The cursor should be ready after the prompt.
yourname@raspberrypi:~ $ ▮Your username or computer name may be different. Do not type the prompt itself.
How a command worksType the command after the prompt, then press Enter. The Pi responds on the next line.
08 · first commands

Ask: where am I, and what is here?

We will use one command at a time. Read what it means before typing it.

1. pwd = print working directory

In plain English: “Tell me which folder I am in.”

  1. In Terminal, type pwd.
  2. Press Enter.
  3. You should see something beginning with /home/. The final part is usually your username.

2. ls = list

In plain English: “Show me what is inside this folder.”

  1. Type ls.
  2. Press Enter.
  3. Look for pi-projects in the list.
If pi-projects is not listedGo back to File Manager and check that the folder is really inside Home and is spelled exactly pi-projects. Then return to Terminal and type ls again.
09 · moving around

Use Terminal to enter the folder

cd means change directory. “Directory” is another word for folder.

  1. Type cd pi-projects and press Enter.
  2. Type pwd and press Enter. The answer should now end in /pi-projects.
  3. Type mkdir first-pi and press Enter. mkdir means make directory.
  4. Type ls. You should now see first-pi.
  5. Type cd first-pi.
  6. Type pwd one more time.
CheckpointThe final answer from pwd should end in /pi-projects/first-pi. Now open File Manager and look inside pi-projects: the same first-pi folder should be there.
If Terminal says “No such file or directory”Type ls and check the spelling of the folder you are trying to enter. Linux cares about spelling, spaces and capital letters.
10 · python editor

Open Thonny

Thonny is the program we will use to write and run Python.

  1. Open the Raspberry Pi menu.
  2. Choose Programming.
  3. Choose Thonny.
  4. Wait for the window to open.

Editor

The large upper area. This is where you type your Python program.

Shell

The lower area. This is where Python shows printed messages and errors when your program runs.

If Thonny is not in the Programming menuTell your tutor. Do not start installing software from random websites.
11 · save first

Create and save hello.py

For this lesson, save the file before you run it. That way you always know where your code lives.

  1. In Thonny choose File → New.
  2. In the editor, type exactly:
print("Hello from the Pi")
  1. Choose File → Save As….
  2. If Thonny asks where to save, choose This computer.
  3. Go to Home → pi-projects → first-pi.
  4. For the file name, type hello.py.
  5. Click Save.
Check before runningThe Thonny window/tab should now show the name hello.py.
12 · run python

Run your saved program

  1. Look at the code once for spelling and matching quote marks.
  2. Click Thonny's green Run button, or choose Run → Run current script.
  3. Look in the Shell area at the bottom of Thonny.
What should appear?Hello from the Pi
If the message does not appearLook in the Shell for red error text. Check that print is spelled correctly, both quote marks are present, both brackets are present, and you saved the file. Fix one thing, save again, then Run again.
What just happened?Thonny sent the contents of hello.py to Python. Python read the instruction and printed your message.
13 · same file, terminal

Run hello.py a second way

Now we will prove that Thonny and Terminal are working with the same file on the same computer.

  1. Leave Thonny open.
  2. Open a Terminal window again.
  3. Type cd ~/pi-projects/first-pi and press Enter. The ~ symbol is a shortcut for your Home folder.
  4. Type ls. Check that hello.py is listed.
  5. Only after you can see the file, type python3 hello.py and press Enter. Here, python3 means “use Python 3” and hello.py is the file you are asking it to run.
What should appear?Hello from the Pi should appear in Terminal.
If it does notIf ls does not show hello.py, you are in the wrong folder or saved the file somewhere else. Use File Manager to find it. If the file is listed but Python shows an error, return to Thonny, fix the code, save, and try again.
The important ideaThere is only one hello.py. Thonny can run it. Terminal can ask Python to run it too.
14 · checkpoint

What can you now do?

Before learning shutdown, check that each of these is actually true.

One last essential skill: switch the Pi off without risking its files.
15 · finish safely

Shut the Raspberry Pi down

Do not finish by pulling out the power cable. Tell the operating system to shut down first.

  1. Save anything still open in Thonny: File → Save.
  2. Click the Raspberry Pi icon at the top-left of the desktop.
  3. Choose Shutdown.
  4. A Shutdown Options window appears. Choose Shutdown again.
  5. Wait. The desktop will disappear and the monitor will go blank.
  6. When the Pi has fully powered down, disconnect the power cable if you need to pack it away.
FinishedYou have now started, used and safely shut down a Raspberry Pi for the first time.
LaterLinux also has typed shutdown commands, but you do not need them yet. The desktop method is the right first habit.