Close
0%
0%

Crystal RGB

Glowing RGB crystal

Similar projects worth following
3D printed RGB desk ornament in the shape of a crystal. I found a pretty design on Thingiverse and wanted to put an RGB LED in it.

Hardware

Arduino sketch - Crystal

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define PIXELPIN          0

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIXELPIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // put your setup code here, to run once:
  
  strip.begin();
  strip.clear();
  strip.show();

}

void loop() {
  // put your main code here, to run repeatedly:
  static uint8_t i = 0;

  strip.setPixelColor(0, Wheel(i));
  strip.show();
  delay(20);
  i++;
}


uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Alternate Arduino sketch - Minerals

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define PIXELPIN          0


#define R   30
#define G   80
#define B   220

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIXELPIN, NEO_GRB + NEO_KHZ800);

void setup() {
  // put your setup code here, to run once:
  
  strip.begin();
  strip.clear();
  strip.show();

}

void loop() {
  // put your main code here, to run repeatedly:
  static uint8_t i = 0;
  static uint8_t dir = 0;
  uint16_t r, g, b;

  r = R * cos(i * DEG_TO_RAD);
  g = G * cos(i * DEG_TO_RAD);
  b = B * cos(i * DEG_TO_RAD);

  strip.setPixelColor(0, r, g, b);
  strip.show();
  delay(20);

  if (i == 60) dir = 1;
  if (i == 0) dir = 0;
  
  if (dir == 0) i++;
  else i--;
}


Credits

Thanks to https://www.thingiverse.com/JustinSDK3d.

  • 1 × Micro-USB Digispark compatible board Small Arduino-compatible board
  • 1 × WS2812B Addressable RGB LED
  • 1 × Micro-USB cable Electronic Components / Misc. Electronic Components
  • 2 × M3 screw

  • 1
    3D print components

    3D print the crystal base from Thingiverse. After this is done, start printing the crystal itself and while it's doing that we will assemble the electronics in the base.

  • 2
    Put in Digispark

    Use two M3 screws to fix the Digispark to the 3D printed base. You might have to use a little force.

  • 3
    Add RGB LED

    Hot glue the LED to the base. Align the LED's marked corner to the bottom right, like in the image.

View all 11 instructions

Enjoy this project?

Share

Discussions

tyler wrote 10/19/2021 at 04:23 point

Fun and very clean, the next thing I would probably do would be some fancy variations based on some random type of sensor maybe (like changing frequency based on barometric pressure?)

  Are you sure? yes | no

mihai.cuciuc wrote 10/19/2021 at 15:42 point

Thanks for your suggestion! I was thinking of adding a light sensor to dim it during the night, but turning it into an actual indicator of something sounds fun!

  Are you sure? yes | no

tyler wrote 10/20/2021 at 01:11 point

No problem, and wherever you go with it have fun!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates