Week 3: RGB LED & Multiple LED’s

This week I am starting to truly get the hang of how the Arduino works, and now the builds are starting to get more challenging. For Week 3, I will be taking on two different circuits — Circuit #3 (RGB LED) and Circuit #4 (Multiple LEDs). These builds are preparing me for my first solo build coming next week. The RGB LED is especially interesting because it’s actually three LEDs (Red, Green, Blue) inside of one single light with four leads — three anodes and one common ground. By changing voltages sent to each anode, I can mix almost any color I want. I am also being introduced to variables and arrays, which allow me to store and use information differently in my code. After exploring these builds and the code associated with each one, my challenge will be to start combining parts of multiple circuits into one program. Instead of writing everything from scratch, I will begin pulling pieces of code from previous builds and merging them together — which is exactly what programmers do in the real world.

RGB LED Code

The following code was used:
// RGB LED blink one color at a time

int RED = 9;

int GREEN = 2;

int BLUE = 3;

void setup() {

pinMode(RED, OUTPUT);

pinMode(GREEN, OUTPUT);

pinMode(BLUE, OUTPUT);

}

void loop() {

// RED

digitalWrite(RED, HIGH);

delay(1000);

digitalWrite(RED, LOW);

delay(500);

// GREEN

digitalWrite(GREEN, HIGH);

delay(1000);

digitalWrite(GREEN, LOW);

delay(500);

// BLUE

digitalWrite(BLUE, HIGH);

delay(1000);

digitalWrite(BLUE, LOW);

delay(500);

}

 

Multiple LEDs Code

The following code was used:
//LED wave effect

int leds[] = {2, 3, 4, 5, 6}; // five LEDs connected to pins 2-6

int totalLEDs = 5;

void setup() {

for(int i = 0; i < totalLEDs; i++){

pinMode(leds[i], OUTPUT);

}

}

void loop() {

// forward wave

for(int i = 0; i < totalLEDs; i++){

digitalWrite(leds[i], HIGH);

delay(250);

digitalWrite(leds[i], LOW);

}

// reverse wave

for(int i = totalLEDs-1; i >= 0; i--){

digitalWrite(leds[i], HIGH);

delay(250);

digitalWrite(leds[i], LOW);

}

}

 

Challenges and Reflections:
This week brought a fresh set of challenges as I shifted from basic circuits to more complex builds with both the RGB LED and the 5-LED wave effect. When I first wired the three-anode / one-cathode RGB LED, I realized I had to pay closer attention to how the pins corresponded to red, green, and blue — and how each value contributes to the final mixed color. That required me to think not just “on/off,” but “what voltage, which LED, what timing.” It felt like a small step in hardware, but a bigger leap in my mental model of how code, pins, and electronics interact.

With the multiple-LED wave effect, I hit a second challenge: managing sequence and direction. Writing the simple forward loop was straightforward, but then I had to invert the sequence for the reverse wave — and I found myself debugging off-by-one errors (“Did I include the 0th LED? Did I go all the way to the last pin?”). That nudged me into deeper territory: arrays, indexing, and the logic of iteration. When the wave stayed in sync, and then reversed cleanly, it was rewarding. When it didn’t, I had to step back, trace the code, re-trace the wiring, and make sure I’d matched the physical circuit to the array indices.

One of the biggest reflections I have is how these builds feel like stepping stones in the programming mindset: reuse, modularity, and combining pieces. I began to see that the code I wrote for the RGB LED doesn’t live in isolation — it’s a module I can “pull into” a larger program. Likewise, the wave effect is a pattern I can reuse, maybe even parameterize. My challenge now is to merge these — maybe the RGB LED changes color while the wave runs — and that is exactly the direction for next week’s solo build.

Finally, I found myself thinking about “what if.” What if I changed the delay times for the wave? What if I used analogWrite on the RGB to fade between colors instead of just blinking? These “what ifs” are the seeds of creativity, and I’m starting to feel comfortable not just following instructions, but adjusting, expanding, and designing my own variations. That confidence — even if still tentative — feels like the real win this week.

Previous
Previous

Week 4: Electronic Dice Machine

Next
Next

Week 2: Digital vs. Analog