Raspberry Pi Lesson 6.2 — Manual GPIO Blink

LessonsRaspberry Pi → Lesson 6.2
Raspberry Pi

Manual GPIO Blink

“No shortcuts. Full control. You tell each pin exactly what to do and when.”

⏱ About 20 minutes 🛠 Raspberry Pi + Thonny ⭐ Lesson 2 of 3

What you will have

A Python script that controls two LEDs independently — each with its own timing, pattern, and behaviour — using direct GPIO control.

Two LEDs, alternating patterns, all under your command.


What you will need

Everything from Lesson 6.1 plus one more LED and resistor.

Two LEDs (different colours if possible), two 330 ohm resistors, jumper wires, breadboard, and your Raspberry Pi.


Your prompt

Copy this. Paste it into your AI. Hit Enter.

📋 Your Prompt — Copy Everything Below
Write a Python script for Raspberry Pi using RPi.GPIO that controls two LEDs manually. LED1 is on GPIO 17, LED2 is on GPIO 27. Create a sequence: LED1 on for 0.5s, then off. LED2 on for 0.5s, then off. Then both on for 1s, then both off for 0.5s. Repeat this sequence 10 times then stop cleanly. Include GPIO cleanup. Add comments explaining each step.
✅ Copied! Now paste it into your AI.

Wire it up

Add a second LED to your existing circuit.

1
Keep LED1 wired to GPIO 17 (physical pin 11)
Same as Lesson 6.1 — nothing changes here.
2
Connect LED2 to GPIO 27 (physical pin 13)
Long leg → GPIO 27. Short leg → 330 ohm resistor → GND.

What to do after

Paste, save, run.

1
Paste the AI code into Thonny
New file → paste → save as manual_gpio.py.
2
Press F5 to run
Watch the sequence play out — LED1, LED2, both, off — 10 times then stop.

🛠️ Didn’t work?

Check these first:

1 Is LED1 on physical pin 11 (GPIO 17)?
2 Is LED2 on physical pin 13 (GPIO 27)?
3 Copy any error from Thonny and paste to your AI: “This didn’t work. Here’s the error: [paste]. Please fix it.”

Vibe Tweak

Change the sequence count.

Find the number 10 — that’s how many times the sequence repeats. Change it to 3.

Find this
range(10)
Change to this
range(3)

Extra Credit

Want to go further?

📋 Extra Credit Prompt
Create a Knight Rider style scanning effect with 3 LEDs on GPIO 17, 27, and 22. The light should scan left to right then right to left continuously — LED1 on, off, LED2 on, off, LED3 on, off, LED2 on, off, LED1 on, repeat. Use a delay of 0.15 seconds between each step.
✅ Copied!

Reflection

Before you move on — think about this.

“You controlled two physical objects independently using code. Each GPIO.output line is a direct command to real hardware. Can you see how this scales? Ten LEDs, a hundred — same principle, more pins.”

Up next — the final lesson
Raspberry Pi Lesson 6.3 — DHT11 Temperature Sensor
Read real temperature and humidity from the world around you. Breathe on the sensor. Watch the numbers change.
Final Lesson →
Greg the Vibe Coder · gregthevibecoder.com 18 lessons · No account required