Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Random Stuff We Make!
Published © CC BY-NC-SA

DIY Chameleon Lamp

An easy DIY lamp which can change its colour like a chameleon. Just show it a different colour & see the magic.

BeginnerFull instructions provided30 minutes6,270

Things used in this project

Hardware components

NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Gravity: TCS34725 RGB Color Sensor For Arduino
DFRobot Gravity: TCS34725 RGB Color Sensor For Arduino
×1
Arduino Nano R3
Arduino Nano R3
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Schematics

Schematics

Replicate this in physical form

Code

Arduino Code

Arduino
Upload it through Arduino IDE
#include <Wire.h>
#include <Adafruit_TCS34725.h>
#include <Adafruit_NeoPixel.h>

#define NUMPIXELS 24
#define LED_PIN 3

#define debug false

byte gammatable[256];

Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, LED_PIN, NEO_GRB+NEO_KHZ800);

void setup() {
  if(debug){
    Serial.begin(115200);
  }
  tcs.begin();
  pixels.begin();
  for (int i = 0; i < 256; i++){
    float x = i;
    x /= 255;
    x = pow(x, 2.5);
    x *= 255;
    gammatable[i] = x;
  }
}

void loop(){
  float r, g, b;
  delay(60);
  tcs.getRGB(&r, &g, &b);
  if(debug){
    Serial.print("R: "); 
    Serial.print(int(r)); 
    Serial.print("\tG: "); 
    Serial.print(int(g)); 
    Serial.print("\tB: "); 
    Serial.println(int(b));
  }
  for(int i = 0; i < NUMPIXELS; i++){
    pixels.setPixelColor(i, pixels.Color(gammatable[(int)r], gammatable[(int)g], gammatable[(int)b]));
  }
  pixels.show();
}

Credits

Random Stuff We Make!

Random Stuff We Make!

17 projects • 64 followers
We at RSWM! try to bring Fiction to Reality through projects which are Interactive, Creative & way too simpler in terms of making.

Comments