Arnov Sharma
Published © MIT

CONE LAMP With XIAO

Made a cone-shaped RGB Lamp from scratch, The lamp consists of WS2812 LEDs that are controlled by an XIAO MCU.

BeginnerFull instructions provided1 hour339
CONE LAMP With XIAO

Things used in this project

Story

Read more

Custom parts and enclosures

cad file

Schematics

Wiring

Code

code

C/C++
#include <Adafruit_NeoPixel.h>

#define PIN            1  // Digital pin connected to the NeoPixels
#define NUMPIXELS      32 // Number of NeoPixels

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int potPin = 0;   // Analog pin connected to the potentiometer
int potValue = 0;  // Variable to store potentiometer value

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  randomSeed(analogRead(0)); // Seed the random number generator
}

void loop() {
  potValue = analogRead(potPin); // Read the potentiometer value

  // Map the potentiometer value to the range of NeoPixel colors (0 - 255)
  int hue = map(potValue, 0, 1023, 0, 255);

  // Change the color of all NeoPixels to the mapped hue
  for (int i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(hue, 0, 255));
  }

  strip.show(); // Update the NeoPixel strip
  delay(100);   // Add a small delay for smoother operation
}

Credits

Arnov Sharma

Arnov Sharma

275 projects • 288 followers
Just your average MAKER

Comments