LED Control Patterns
📖 Scenario: You are programming a simple embedded system with 4 LEDs connected to a microcontroller. You want to create different light patterns by turning LEDs on and off in a sequence.
🎯 Goal: Build a program that controls 4 LEDs using an array to represent their states, then create a pattern that turns LEDs on one by one, and finally print the LED states to simulate the output.
📋 What You'll Learn
Create an array called
leds with 4 elements initialized to 0 (off).Create a variable called
current_led to track which LED to turn on.Write a loop that sets the
current_led element in leds to 1 (on) and others to 0 (off).Print the
leds array states to show which LEDs are on or off.💡 Why This Matters
🌍 Real World
Embedded systems often control LEDs to show status or alerts. Learning to manage LED patterns is a basic skill for hardware programming.
💼 Career
Embedded software developers and hardware engineers use similar code to control lights and indicators on devices.
Progress0 / 4 steps