Creative LED Strip of the Skill I Learned
Creative LED Strip of the Skill I Learned
What I wanted to learn, and why it interested me: I wanted to learn how to control an LED strip because I was interested in creating colorful light effects.
Final outcome: For my creative output, I made a rainbow flowing light effect controlled by two buttons: one button reverses the direction of the color flow, and the other switches between slow and fast speed.
Images of final creative/exploratory output
Final demo: the LED strip displays a flowing rainbow effect. Pressing one button reverses the direction of the color flow, and pressing the other button toggles between slow and fast speed.
LED strip showing the rainbow flowing effect, with each LED displaying a different color along the strip.
Process images from development towards creative/exploratory output
Early testing of the LED strip with two buttons on the breadboard, debugging why one button was not responding.
Breadboard setup showing the Arduino, LED strip, and two tactile buttons wired to pins 3 and 4.
Process and reflection:
I started by following the course tutorial and running the sample code to get the LED strip lighting up.
I initially wanted to make two buttons control colors spreading from each end of the strip, meeting in the middle with a blended color. I ran into a frustrating problem where one of the buttons was not responding. After a lot of debugging, including checking the wiring and adding Serial Monitor tests, I confirmed the hardware was fine but the button press was being missed by the code due to timing issues with the LED strip data transmission.
I decided to change direction and made a rainbow flowing light effect instead, where one button reverses the flow direction and the other changes the speed. This experience taught me that debugging hardware and software together can be time-consuming, and that being flexible with your creative goals is an important skill. I am happy with the final result because the rainbow effect is visually satisfying and the buttons make it feel interactive.
Technical details
Electrical schematic: LED strip DI connects to pin 2, GND and 5V connect to Arduino GND and 5V. Two tactile buttons connect between pins 3/4 and GND, using internal pull-up resistors.
/*
60-223 Intro to Physical Computing, Spring 2026
Domain-specific Skill Building: Rainbow flowing LED strip
This sketch drives a WS2812B LED strip with a rainbow color effect.
The colors flow continuously along the strip. One button (pin 3)
reverses the direction of the flow, and another button (pin 4)
toggles between slow and fast speed.
Pin mapping:
Arduino pin | role | details
--------------------------------
2 output LED strip data (DI)
3 input tactile button - reverse direction
4 input tactile button - toggle speed
Coral Zhu, xiangcuz@andrew.cmu.edu
*/
#include <Adafruit_NeoPixel.h>
const int LED_DATA_PIN = 2;
const int NUM_LEDS = 30;
const int BTN_LEFT = 3;
const int BTN_RIGHT = 4;
Adafruit_NeoPixel leds(NUM_LEDS, LED_DATA_PIN, NEO_GRB + NEO_KHZ800);
int offset = 0;
int direction = 1;
int speed = 200;
bool lastBtnLeft = HIGH;
bool lastBtnRight = HIGH;
void setup() {
pinMode(BTN_LEFT, INPUT_PULLUP);
pinMode(BTN_RIGHT, INPUT_PULLUP);
leds.begin();
leds.clear();
leds.setBrightness(50);
leds.show();
}
void loop() {
bool btnLeftState = digitalRead(BTN_LEFT);
bool btnRightState = digitalRead(BTN_RIGHT);
if (btnLeftState == LOW && lastBtnLeft == HIGH) {
direction = -direction;
}
if (btnRightState == LOW && lastBtnRight == HIGH) {
if (speed == 100) speed = 2000;
else speed = 100;
}
lastBtnLeft = btnLeftState;
lastBtnRight = btnRightState;
for (int i = 0; i < NUM_LEDS; i++) {
int hue = map(i, 0, NUM_LEDS - 1, 0, 65535) + offset;
leds.setPixelColor(i, leds.ColorHSV(hue, 255, 255));
}
leds.show();
offset += speed * direction;
delay(20);
}