mihai.cuciuc
Published © MIT

Crystal RGB

Glowing RGB crystal

IntermediateFull instructions provided4 hours603
Crystal RGB

Things used in this project

Hardware components

Micro-USB Digispark compatible board
×1
WS2812B addressable RGB LED
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Machine Screw, M3
Machine Screw, M3
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
3D Printer (generic)
3D Printer (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

3D models

CrystalBase

Crystal

Schematics

Wiring diagram

Code

Arduino sketch

Arduino
Code that needs to be programmed to the Digispark to control the addressable LED. This cycles through the color wheel. Code is a much simplifed version of an example from the Adafruit NeoPixel library.

You need the Digistump AVR boards installed in Arduino and the Adafruit NeoPixel library.
#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);
}

Arduino Minerals sketch

Arduino
This sketch pulses blue, in an attempt to look like a mineral field from a popular RTS game.
#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

mihai.cuciuc
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.