Skip to content

Add in Raspberry gpio pages #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
be40da1
Add new projects: Binary Calculator and Judgement Game; introduce Ras…
XQuestCode Mar 20, 2025
4960e28
Add new guides for Raspberry Pi control flow and potentiometer usage;…
XQuestCode May 29, 2025
21ba3be
Merge branch 'raspberry-pi-tasks' of https://github.com/XQuestCode/th…
omckeon Jul 7, 2025
3e78664
Remove unwanted files
omckeon Jul 7, 2025
ef1313e
Update Part 0 Raspberry Pi pages
omckeon Jul 10, 2025
6f1b78e
Simplify the P0C3 Raspberry Pi guided activity.
omckeon Jul 10, 2025
70f3493
Add attributions for RPi images in P0C2
omckeon Jul 11, 2025
8702c58
Update blink LED diagram and add attribution
omckeon Jul 11, 2025
f1d2712
Update Pi installation page to add links for more information about c…
omckeon Jul 14, 2025
8041b51
Update P0C3 Gpio pages
omckeon Jul 14, 2025
54e7c07
Update file names to fix order in sidebar to have raspberry pi at the…
omckeon Jul 14, 2025
b487e64
P1C1 - Add initial 7-segment display content to overview section
omckeon Jul 15, 2025
e49224c
Update circuits diagrams to make it easier for moving to the 7-segmen…
omckeon Jul 15, 2025
f7b0c7e
Update diagram and move simplified pinout to guided tour
omckeon Jul 15, 2025
4425935
Initial plan for P1C1 guided tour
omckeon Jul 15, 2025
0762478
Move pages into control flow chapter - reading GPIO pin focus
omckeon Jul 15, 2025
8678487
P1C1 - Add in plan for gpio test your knowledge activity.
omckeon Jul 15, 2025
633d4b3
Update P1C1 Overview for GPIO
omckeon Jul 17, 2025
c3e098e
Move button press pages back to P1C1
omckeon Jul 17, 2025
75a9e6c
Update P1C1 overview pages
omckeon Jul 18, 2025
5919d54
Update P1C1 GPIO guided tour pages
omckeon Jul 18, 2025
171aa0f
Move 7-segment pages to P2C2
omckeon Jul 18, 2025
56aa91e
Rename pages
omckeon Jul 18, 2025
5b2763b
Update 7-seg pages
omckeon Jul 18, 2025
ccaacd0
Fix broken links
omckeon Jul 18, 2025
d9542a4
Merge branch 'main' of https://github.com/splashkit/the-programmers-f…
omckeon Jul 18, 2025
eba3ace
Add note with link to guided activity
omckeon Jul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified resources/guide-diagrams-olivia.graffle
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Building programs really requires that you have access to a computer that you ca
Using the _Raspberry Pi_ Multi-tool will give you several advantages:

- You can play around with Unix without risking your day-to-day computer (which you can switch to Linux once you are more confident)
- The Raspberry Pi include pins for **General Purpose Input / Output** (**GPIO**) though a [40-pin header](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-and-the-40-pin-header) on the board:
- The Raspberry Pi include pins for **General Purpose Input / Output** (**GPIO**) though a [40-pin header](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio) on the board:

![Raspberry Pi 40-pin header](https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png)
<div class="caption">Image © Raspberry Pi Ltd, licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> (CC BY-SA)</div>
Expand Down Expand Up @@ -259,6 +259,22 @@ This is the list of components we used to build our multi-tool with links to Aus
- 1 x [ModMyPi Modular RPi 2 Case - VESA Splash (75/100mm)](https://core-electronics.com.au/modmypi-modular-rpi-2-case-vesa-splash-75-100mm.html)
- 1 x [USB C Power Delivery Battery Bank 20000mAh](https://core-electronics.com.au/usb-c-pd-battery-bank-20000mah.html)

:::note
When working with the GPIO pins, it can be tricky to find the right pins when trying to connect your wires. You can use a GPIO Breakout board, or a case with this built in.

Here are some options for GPIO Breakout boards:

- [Raspberry Pi GPIO Breakout Lead and Header for breadboard (Jaycar)](https://www.jaycar.com.au/raspberry-pi-gpio-breakout-lead-and-header-for-breadboard/p/XC9042)
- [40-pin Raspberry Pi GPIO Breakout](https://core-electronics.com.au/40-pin-raspberry-pi-gpio-breakout.html)

An alternative option (highly recommended):

- [Argon ONE V2 Raspberry Pi 4 Case](https://core-electronics.com.au/argon-one-v2-raspberry-pi-4-case.html)

_This case for the Raspberry Pi 4 includes a built in colour-coded GPIO header with both pin numbers and pin descriptions, which is easy to access by removing a magnetic cover._

:::

## 2. Building your multi-tool

:::tip
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Raspberry Pi!
sidebar:
attrs:
class: pi
---

import { Steps } from "@astrojs/starlight/components";

## What’s a Raspberry Pi, Anyway?

![Raspberry Pi](./images/raspberrypi.png)
<div class="caption">Image from <a href="https://learn.littlebirdelectronics.com.au/guides/getting-started-with-the-raspberry-pi-4">Little Bird Electronics</a></div>

Imagine having a mini-computer that fits in the palm of your hand—cool, right? The Raspberry Pi is exactly that! It’s a tiny, affordable computer packed with power and endless possibilities. Whether you want to create your own video game, build a robot, or set up a secret spy project, the Raspberry Pi is your launchpad for creativity and fun.

:::note[Did You Know?]
Raspberry Pi was created to make computer science accessible and enjoyable for everyone. With its friendly size and versatile capabilities, it’s like a magic box that turns your ideas into reality!
:::

### Why Are We Using It?

Learning with the Raspberry Pi is like mixing science with a dash of adventure. Here’s what makes it so awesome:

- **Hands-On Fun:** You get to see the results of your code come alive—lighting up LEDs, moving motors, or even playing sounds!
- **Creative Exploration:** Tinker with sensors, buttons, and displays. Every project is an exciting opportunity to learn something new.
- **Easy to Start:** Even if you’re new to programming, the Raspberry Pi offers a gentle introduction with plenty of support.
- **Real-World Experience:** From simple experiments to complex projects, it’s the perfect tool to learn how software and hardware work together.

## What’s in Store for You?

In our course, you’ll embark on a thrilling journey where you’ll:

<Steps>

1. **Learn the Basics:** Understand programming fundamentals in a clear, straightforward way.
2. **Explore Embedded Systems:** Discover how code interacts with real-life gadgets and electronics.
3. **Build Awesome Projects:** From a blinking LED to your very own interactive device, you’ll create projects that are both fun and impressive.

</Steps>

### Need a Little Extra Help?

If you ever want to dive deeper, here are some official guides and resources you can explore:

- **[Getting Started with Raspberry Pi](https://www.raspberrypi.com/documentation/)**

This guide is perfect for beginners. It walks you through setting up your Raspberry Pi, installing the operating system, and getting your first project up and running. It’s like a friendly roadmap that makes your first steps in the world of computing smooth and enjoyable.

- **[Raspberry Pi Projects](https://projects.raspberrypi.org/en/)**

Looking for inspiration? Check out this treasure trove of projects. Whether you’re into art, science, or robotics, you’ll find ideas and step-by-step instructions to ignite your creativity.

:::tip
Remember, every big programmer started as a beginner. Don’t worry about making mistakes—they’re simply stepping stones to mastering new skills. Have fun, experiment boldly, and let your curiosity lead the way!
:::

Get ready to have a blast learning and creating with your Raspberry Pi. Let’s turn those brilliant ideas into real-world projects—one exciting step at a time!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: Use Your Raspberry Pi
sidebar:
attrs:
class: pi
---

## How Does Raspberry Pi Work?

Think of the Raspberry Pi as a mini-computer that packs a serious punch in a tiny package. Inside, it has a processor, memory, and storage (thanks to its microSD card) that allow it to run a full operating system, usually Raspberry Pi OS. This little computer isn’t just about crunching numbers—it’s also built to interact with the world around you!

:::note[Inside the Magic]
At its heart, the Raspberry Pi has a CPU (the brain), RAM (its short-term memory), and various ports like HDMI and USB. But the real magic happens with its GPIO pins!
:::

## Understanding the GPIO Pins

![Raspberry Pi 40-pin header](https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png)
<div class="caption">Image © Raspberry Pi Ltd, licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> (CC BY-SA)</div>

The **General Purpose Input/Output (GPIO)** pins are like a set of super-flexible connectors on your Raspberry Pi. Here’s how you can use them:

- **Input Mode:**
You can attach sensors (like temperature or light sensors) to the pins. The Raspberry Pi can read signals from these sensors to understand its environment.

- **Output Mode:**
Connect LEDs, motors, buzzers, and more! With a bit of code, you can make an LED blink, a motor spin, or even create sound effects.

- **Digital and PWM Signals:**
Some pins work in a digital on/off mode (perfect for simple tasks), while others support Pulse Width Modulation (PWM), which lets you control the speed of a motor or the brightness of an LED by varying the power output.

:::caution[Always check your project’s voltage requirements]
The Raspberry Pi’s GPIO pins work with 3.3V logic. Overloading them with higher voltage can damage your board.
:::

## Utilizing the Power of Raspberry Pi

By combining programming with hardware, you can create projects that respond to real-world events. Here are a few ideas:

- **Interactive LED Displays:**
Use GPIO pins to control an array of LEDs that react to sensor input or your code commands.

- **Home Automation:**
Control devices like fans, lights, or alarms with your own custom scripts.

- **Robotics:**
Connect motors and sensors to build a robot that can navigate and react to its surroundings.

Each project is an opportunity to see your code make a tangible difference. With the GPIO pins as your bridge between software and hardware, you can bring your creative ideas to life!

## Getting Started: Setup Your Raspberry Pi

Before you start exploring the endless possibilities, you need to get your Raspberry Pi up and running. For a step-by-step guide on setting up the Raspberry Pi OS (including downloading the OS, installing it on your microSD card, and initial configuration), follow the instructions here:

[Setup Raspberry Pi OS](/book/appendix/0-installation/2-3-setup-pi/#3-setup-raspberry-pi-os)

Read through this guide carefully--It walks you through everything from burning the OS image to your SD card to configuring your Pi’s settings like the keyboard layout, Wi-Fi network, and more.

:::tip
*Take your time during setup* and don’t be afraid to explore! Every step is a learning opportunity, and once you have your Raspberry Pi ready, you’re on your way to building amazing projects.
:::

Happy tinkering, and may your experiments spark innovation and endless fun!
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
title: Hello LED Blinking
sidebar:
attrs:
class: pi
---

import { Accordion, AccordionItem } from 'accessible-astro-components'
import { Steps } from "@astrojs/starlight/components";

Welcome to our fun, step-by-step guide on how to blink a physical LED using SplashKit on your Raspberry Pi! In this tutorial, you'll learn how to set up your hardware, write simple code to turn your LED on and off multiple times, as well as how to run your project. Get ready to see your LED come to life!

## Hardware Setup

### Components

To build the simple LED circuit shown below (in real life), here's what you need:

- **LED:** Can be any color.
*Remember: the longer leg is the anode (+), the shorter is the cathode (-).*
- **220 Ω Resistor:** This protects the LED by limiting the current.
- **Breadboard and Jumper Wires:** For making temporary connections.
- **Raspberry Pi:** With a GPIO pin (we'll use GPIO Pin 11) and a Ground (GND) pin.

:::note[Just getting started with circuits?]

These sections include links with more information about the circuit components:

<details>
<summary>LEDs and Resistors:</summary>

- [LEDs (Introduction to Raspberry Pi Pico guide)](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/7)
- [Resistors (Introduction to Raspberry Pi Pico guide)](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/6)
- [Resistors for LED Circuits](https://eepower.com/resistor-guide/resistor-applications/resistor-for-led/)

</details>
<details>
<summary>Breadboards and Jumper Wires:</summary>

- [How to Use a Breadboard for Electronics and Circuits](https://www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard)
- [What is inside a breadboard?](https://www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard#inside-breadboard)
- [How are the holes connected?](https://www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard#holes)
- [What is a breadboard diagram?](https://www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard#breadboard-diagram)
- [What are jumper wires and what kind should I use?](https://www.sciencebuddies.org/science-fair-projects/references/how-to-use-a-breadboard#jumper-wires)

</details>
:::

### Wiring Instructions

![Led Blink Circuit](./images/blinkledcircuit.png)
<div class="caption">Image created with <a href="https://fritzing.org/">Fritzing</a></div>

<Steps>

1. **Put the LED and resistor onto the breadboard:**

Place the resistor across the center channel of the breadboard, or across any two separate rows.

Then place the LED across two rows (as shown in the breadboard diagram above), with the cathode (short leg) on the same row as one end of the resistor.

2. **Attach the ground wire:**

Attach a jumper wire from the other end of the resistor to a GND pin.
*(This is the black wire connected to pin 6 in the diagram above.)*

3. **Connect the LED to the GPIO Pin:**

Attach a jumper wire from the LED’s anode (long leg) to GPIO Pin 11.
*(This is the blue wire connected to pin 11 in the diagram above.)*

</Steps>

:::caution[Safety Note:]
Always double-check your connections and ground yourself before handling the circuit to avoid static discharge or accidental damage.
:::

## Software Setup

To set up the software side of this project, you can follow the steps below:

<Steps>

1. ### Create a new C# project

Open your terminal and create a new C# console project:

```shell
mkdir LedBlink
cd LedBlink
dotnet new console
dotnet add package SplashKit
code .
```

2. ### Write the code

Copy the code below, then replace the contents of your `Program.cs` file with this code:

```csharp
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

// Initialise the GPIO system
RaspiInit();

// Define the LED pin (using physical Pin 11)
GpioPin ledPin = GpioPin.Pin11;

// Set the LED pin to output mode
RaspiSetMode(ledPin, GpioPinMode.GpioOutput);

// Blink 1: Turn LED ON, wait, then OFF
RaspiWrite(ledPin, GpioPinValue.GpioHigh);
Delay(500); // LED ON for 500 ms
RaspiWrite(ledPin, GpioPinValue.GpioLow);
Delay(500); // LED OFF for 500 ms
// Blink 2: Turn LED ON, wait, then OFF
RaspiWrite(ledPin, GpioPinValue.GpioHigh);
Delay(500);
RaspiWrite(ledPin, GpioPinValue.GpioLow);
Delay(500);

// Blink 3: Turn LED ON, wait, then OFF
RaspiWrite(ledPin, GpioPinValue.GpioHigh);
Delay(500);
RaspiWrite(ledPin, GpioPinValue.GpioLow);
Delay(500);

// Clean up the GPIO system
RaspiCleanup();
```

:::note
You will learn more about SplashKit's Raspberry Pi code in Part 1, but for now you can just copy/paste this code without needing to know the details just yet.
:::

3. ### Start the "pigpiod" Daemon

Underneath SplashKit we use the [Pigpio library](https://abyz.me.uk/rpi/pigpio), specifically its
daemon. To interface with this daemon, it must be running.

:::tip[Daemons]
A daemon is a background process that runs continuously, waiting for requests to
perform some action. In this case, the daemon is waiting for requests to change the state of the
GPIO pins. This allows us to run multiple programs that interact with the GPIO pins.
:::

To start the `pigpiod` daemon, run the following command:

```shell
sudo pigpiod
```

To stop the daemon from running, you can use the command:

```shell
sudo killall pigpiod
```

:::note[Pigpiod Error Message]

If the `pigpiod` daemon is not running, you will the following error message in your terminal:

```shell
ERROR [default] Pigpio error: bad connect.
```

:::

4. ### Build and run the project

Use the following command to build and run the program:

```shell
dotnet run
```

</Steps>

## Expected Outcome

When you run the program, your physical LED connected to GPIO Pin 11 should blink on and off three times. Each "on" state lasts for 500 milliseconds followed by an "off" state for 500 milliseconds. Once the sequence is complete, the program cleans up the GPIO settings and exits.

![Led Blinking](./images/LedBlinkSlow.gif)

Enjoy watching your LED blink and have fun tinkering with your Raspberry Pi projects!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading