LED Strip
Sophie Heap
Sophie Heap
What I wanted to learn, and why it interested me: This interested me because I know LEDs are used in almost all projects like this, and that while they are simple, they can make things look super cool. While I had some experience from the double transducer project and working with RGB LEDs i wanted to see how to order them. I think the biggest thing I learned while doingmy own little project was the brightness and values to get diffrent color as well as making if statements inside a loop.
Final outcome: In this mini project, I was able to set it so that a light appears to move across the LED strip controlled by a potentiometer. When the light reaches the end of the strip, it switches color, with the end light color being shown.
Images of final creative/exploratory output
Final setup of the LED strip and the potentiometer
Video of it working
Process images from development towards creative/exploratory output
First test of getting LEDs to light up with test code
Getting the potentiometer to sink with the LED strip
Process and reflection:
After getting the test code to work, I wanted to modify it so that the potentiometer could control the LED strip based on position. My first goal was to have it light up one LED at a time, depending on the potentiometer’s value. Once I was able to get it to register correctly and light each LED individually, I worked on clearing the strip so that only one LED was lit at a time rather than leaving a trail.
After that was functioning properly, I began adding additional colors. I started with a single color that would switch once it reached the end of the strip. Once I got that working smoothly, I added a second color so that it would bounce back in a different color.
While working on the bouncing color effect, I learned a lot about how to make the light appear as though it were switching directions. In the code, this required using a temporary variable to properly swap and store color values. Additionally, while setting up the lights, I learned a lot about brightness control. Mixing “true” colors with RGB LEDs can be challenging, especially since there is no actual white LED, so not all colors are perfectly achievable.
Overall, I feel good about where I ended up. The process helped me better understand how to manage state changes in code and how small adjustments in logic can dramatically change the visual outcome.
Technical details
Electrical schematic. (In my project, I used a LED strip with 30 LEDs )
/*
60-223 Intro to Physical Computing, fall 2025
Domain-specific Skill Building exercise: LED color bouncing
light is controlled ny potenteometer and when reached, left or right
end of the strip switched colors with whatever is lit up on the ends
Pin mapping:
Arduino pin | role | details
------------------------------
2 output LEDs
6 input potentiometer
Sophie Heap, sheap@andrew.cmu.edu
*/
#include <Adafruit_NeoPixel.h>
const int LED_DATA_PIN = 2;
const int NUM_LEDS = 30;
Adafruit_NeoPixel leds(NUM_LEDS, LED_DATA_PIN, NEO_GRB + NEO_KHZ800);
// Colors that remember their values
uint32_t rightColor;
uint32_t leftColor;
uint32_t moveColor;
int previousPosition = -1; // stores last LED position
void setup() {
leds.begin();
leds.setBrightness(100);
leds.show();
// Starting colors
rightColor = leds.Color(0, 255, 0); // green
leftColor = leds.Color(0, 0, 255); // blue
moveColor = leds.Color(255, 0, 0); // red
}
void loop() {
// Read potentiometer
int potValue = analogRead(A0);
if (potValue > 1015) potValue = 1023;
if (potValue < 8) potValue = 0;
// Convert potentiometer value to LED position (0–29)
int position = map(potValue, 0, 1023, 0, NUM_LEDS - 1);
// If reached the right end (LED 0), swap colors
if (position == 0 && previousPosition != 0) {
uint32_t temp = moveColor;
moveColor = rightColor;
rightColor = temp;
}
// If reached the left end swap colors
if (position == NUM_LEDS-1 && previousPosition != NUM_LEDS-1) {
uint32_t temp = moveColor;
moveColor = leftColor;
leftColor = temp;
}
// Clear strip before drawing
leds.clear();
// Set right end LED if mover is not there
if (position != 0) {
leds.setPixelColor(0, rightColor);
}
// Set left end LED if mover is not there
if (position != NUM_LEDS - 1) {
leds.setPixelColor(NUM_LEDS - 1, leftColor);
}
// Set moving LED
leds.setPixelColor(position, moveColor);
// Update strip
leds.show();
// Save current position for next loop
previousPosition = position;
delay(20);
}