0
0
Raspberry Piprogramming~30 mins

Multiple LED patterns in Raspberry Pi - Mini Project: Build & Apply

Choose your learning style9 modes available
Multiple LED patterns
📖 Scenario: You have a Raspberry Pi connected to three LEDs on pins 17, 27, and 22. You want to create different light patterns to make the LEDs blink in fun ways.
🎯 Goal: Build a program that controls three LEDs to blink in two different patterns: first all LEDs blink together, then they blink one by one in a sequence.
📋 What You'll Learn
Use the gpiozero library to control LEDs
Create a list of LED objects for pins 17, 27, and 22
Write code to blink all LEDs together three times
Write code to blink LEDs one by one in sequence three times
Print messages to show which pattern is running
💡 Why This Matters
🌍 Real World
Controlling LEDs on a Raspberry Pi is a common way to learn about hardware programming and create visual signals or indicators.
💼 Career
Understanding how to control hardware components like LEDs is useful for jobs in embedded systems, IoT development, and electronics prototyping.
Progress0 / 4 steps
1
Set up LEDs on pins 17, 27, and 22
Import LED from gpiozero and create a list called leds with three LEDs on pins 17, 27, and 22.
Raspberry Pi
Need a hint?

Use LED(pin_number) to create each LED object and put them inside a list named leds.

2
Set blink count
Create a variable called blink_count and set it to 3 to control how many times the LEDs will blink.
Raspberry Pi
Need a hint?

This variable will help repeat the blink patterns the right number of times.

3
Write LED blink patterns
Write a for loop using blink_count to blink all LEDs together by turning them on, waiting 0.5 seconds, then turning them off and waiting 0.5 seconds. Then write another for loop to blink each LED one by one in sequence with the same timing.
Raspberry Pi
Need a hint?

Use nested loops: outer loop repeats the pattern, inner loop controls LEDs. Use time.sleep(0.5) to pause.

4
Print pattern messages
Add print statements before each pattern to show "Blinking all LEDs together" and "Blinking LEDs one by one". Then run the program to see the messages and LED patterns.
Raspberry Pi
Need a hint?

Use print() before each pattern loop to show which pattern is running.