Arduino Lesson 5.3 — Mood Light

LessonsArduino → Lesson 5.3
Arduino

Mood Light

“Three colours. One button. You set the mood.”

⏱ About 25 minutes 🛠 Arduino IDE + Arduino board ⭐ Lesson 3 of 3

What you will need

Your Arduino, button, and three LEDs — red, green, and blue.

Three LEDs in different colours, three 220 ohm resistors, a push button, jumper wires, and a breadboard.


What you will have

Three LEDs that cycle through different lighting moods each time you press the button — red, green, blue, all three, and off.


Video Walkthrough

Watch the full lesson walkthrough.


Your prompt

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

📋 Your Prompt — Copy Everything Below
Write an Arduino sketch for a mood light. A red LED is on pin 11, a green LED on pin 10, a blue LED on pin 9. A push button is on pin 7 with INPUT_PULLUP. Each button press cycles through these moods in order: 1) Red only, 2) Green only, 3) Blue only, 4) All three on together, 5) All off. Then back to red. Include button debouncing. Add comments explaining each mood state.
✅ Copied! Now paste it into your AI.

Wire it up

Three LEDs and one button.

1
Red LED — long leg to pin 11, short leg via resistor to GND
Use a 220 ohm resistor between the short leg and GND.
2
Green LED — long leg to pin 10, short leg via resistor to GND
Same setup as the red LED.
3
Blue LED — long leg to pin 9, short leg via resistor to GND
Same setup as the other LEDs.
4
Button — one leg to pin 7, other leg to GND
Same as Lesson 5.2.
Arduino Uno wiring diagram showing three LEDs on pins 9, 10, 11 and a button on pin 7

Your wiring should look like this — red to pin 11, green to pin 10, blue to pin 9, each with its own resistor to GND. Button on pin 7.


🛠️ Didn’t work?

Check these first:

1 Are all three LEDs wired with long leg to the correct pin?
2 Does each LED have its own resistor to GND?
3 Copy any error and paste to your AI: “This didn’t work. Here’s the error: [paste]. Please fix it.”

Vibe Tweak

Feel the difference debouncing makes.

Find the delay value in the debounce section — it’ll be something like 50. That’s 50 milliseconds. Change it to 200. Restart the simulation and press the button fast. See how it doesn’t jump states? That’s debouncing doing its job.

Find this
delay(50)
Change to this
delay(200)

Change it back to 50 and try again. Now try 10. You can feel the difference. One number. Changes the whole feel of the button.


Extra Credit

Want to go further?

📋 Extra Credit Prompt
Update the mood light sketch to add a fifth state: all three LEDs on at once as a full white mode. Also add a sixth state where the LEDs cycle automatically — red, yellow, green, repeating every half second — until the button is pressed again to stop.
✅ Copied!

Now you’ve got an automatic cycling mode. That’s an interrupt in everything but name. Real product behaviour from one prompt.


Reflection

Arduino complete. Think about this.

“You built three physical projects — a blinking light, an interactive button, and a mood lamp. These aren’t simulations. They’re real objects doing real things because of your code.”

Arduino Complete! One subject left.
Raspberry Pi — the final subject.
A full Linux computer the size of a credit card. Read real sensors. Control GPIO pins with Python.
Start Raspberry Pi →
Greg the Vibe Coder · gregthevibecoder.com 18 lessons · No account required