November 9, 2024
Description
Create a Stunning RGB Table Decor with Arduino Control!
Transform any space with this easy-to-build, Arduino-controlled RGB table decor featuring a 3x3 grid of vibrant squares. Each square lights up in customizable colors, perfect for adding dynamic lighting to your home, office, or events. Powered via USB for convenience, this project is simple to set up and offers endless possibilities for color combinations and patterns. Whether you’re a DIY enthusiast, a beginner with Arduino, or someone who loves tech-driven decor, this RGB table is a showstopper that combines functionality and creativity!
Key Features:
Required Components:
Build your own RGB table and add a unique lighting element to your space today!
Here is the Arduino code:
#include <Adafruit_NeoPixel.h>
#define PIN 6 // Pin connected to the NeoPixels
#define NUM_PIXELS 9 // Total number of pixels (3x3 grid)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Define the positions of the 3x3 grid (total 9 pixels)
int pixelPositions[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
// Define unique colors for each block
uint32_t colors[9] = {
strip.Color(255, 0, 0), // Red
strip.Color(0, 255, 0), // Green
strip.Color(0, 0, 255), // Blue
strip.Color(255, 255, 0), // Yellow
strip.Color(255, 0, 255), // Purple
strip.Color(0, 255, 255), // Cyan
strip.Color(255, 165, 0), // Orange
strip.Color(75, 0, 130), // Indigo
strip.Color(255, 255, 255) // White
};
// Function to gradually change the color of each pixel
void fadeToColor(int pixel, uint32_t targetColor, int delayTime) {
uint8_t r = (targetColor >> 16) & 0xFF;
uint8_t g = (targetColor >> 8) & 0xFF;
uint8_t b = targetColor & 0xFF;
uint8_t currentR = (strip.getPixelColor(pixel) >> 16) & 0xFF;
uint8_t currentG = (strip.getPixelColor(pixel) >> 8) & 0xFF;
uint8_t currentB = strip.getPixelColor(pixel) & 0xFF;
// Fade the colors gradually
for (int i = 0; i <= 255; i++) {
uint8_t newR = currentR + (r - currentR) * i / 255;
uint8_t newG = currentG + (g - currentG) * i / 255;
uint8_t newB = currentB + (b - currentB) * i / 255;
strip.setPixelColor(pixel, newR, newG, newB);
strip.show();
delay(delayTime);
}
}
void setup() {
strip.begin(); // Initialize the strip
strip.show(); // Initialize all pixels to off
}
void loop() {
// Gradually transition to each color for each block in the grid
for (int i = 0; i < NUM_PIXELS; i++) {
fadeToColor(i, colors[i], 20); // Transition to color with a delay for smooth fade
}
delay(1000); // Keep the colors for 1 second before transitioning again
}
License:
BSD License