DIY GUY Chris
Published © Apache-2.0

Glowing RGB LED Magic Cube (WS2812)

This is certainly inspirational, I detail the full making steps of a cool glowing Magic LED Cube, all necessary files are included.

IntermediateFull instructions provided2 days1,701
Glowing RGB LED Magic Cube (WS2812)

Things used in this project

Hardware components

RP2040
Raspberry Pi RP2040
×1
SparkFun RGB LED Breakout - WS2812B
SparkFun RGB LED Breakout - WS2812B
×1
USB Cable, USB Type C Plug
USB Cable, USB Type C Plug
×1
JLCPCB Customized PCB
JLCPCB Customized PCB
×1

Software apps and online services

Arduino IDE
Arduino IDE
Circuit Maker
CircuitMaker by Altium Circuit Maker

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Paste, Rework
Solder Paste, Rework
Hot Plate, 800 W
Hot Plate, 800 W
3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Cube assembly aid

Cube stand (Base)

Cube stand (Cover)

Cube stand (Holder)

Schematics

Schematic

BOM File

Pick and Place file (for PCBA)

GERBER File

Code

LED Cube code

Arduino
#include <NeoPixelConnect.h>
NeoPixelConnect MyCube(9, 150);
void setup() 
{
}

void loop() 
{
  discoMode(5);
  glowLightRandom(2);
  randomLightShow(1000);
  smoothColorShow(3);
  slideMoveFast(3);
}

void discoMode(int repeat)
{
  for(int i=0; i<repeat ; i++)
  {
    int colorSetRed=random(0,255)/32;
    int colorSetGreen=random(0,255)/32;
    int colorSetBlue=random(0,255)/32;
    int brightnessRed=colorSetRed*5;
    int brightnessGreen=colorSetGreen*5;
    int brightnessBlue=colorSetBlue*5;
    for(int j=0 ; j<30 ; j++)
    {
      int firstPixel=random(0,149);
      for(int i=0; i<3 ; i++)
      {
        MyCube.neoPixelFill(colorSetRed,colorSetGreen,colorSetBlue,true);
        delay(1);
        MyCube.neoPixelSetValue(firstPixel,brightnessRed,brightnessGreen,brightnessBlue,true);
        delay(1);
        MyCube.neoPixelClear();
      }
    }
  }
}
void slideMoveFast(int repeat)
{
  for(int i=0 ; i<repeat ; i++)
  {
    MyCube.neoPixelClear(true);
    for(int i=0 ; i<150 ; i++)
    {
      MyCube.neoPixelSetValue(i,random(0,128),random(0,128),random(0,128),true);
      delay(10);
    }
    for(int i=0 ; i<150 ; i++)
    {
      MyCube.neoPixelSetValue(i,0,0,0,true);
      delay(10);
    }
  }
}
void smoothColorShow (int repeat)
{
  for(int i=0 ; i<repeat ; i++)
  {
    for(int i=255; i>=0; i--)
    {
      MyCube.neoPixelFill((0/10),(255/10),(i/10),true);
      delay(3);
    }
    for(int i=0; i<256; i++)
    {
      MyCube.neoPixelFill((i/10),(255/10),(0/10),true);
      delay(3);
    }
    for(int i=255; i>=0; i--)
    {
      MyCube.neoPixelFill((255/10),(i/10),(0/10),true);
      delay(3);
    }
    for(int i=0; i<256; i++)
    {
      MyCube.neoPixelFill((255/10),(0/10),(i/10),true);
      delay(3);
    }
    for(int i=255; i>=0; i--)
    {
      MyCube.neoPixelFill((i/10),(0/10),(255/10),true);
      delay(3);
    }
    for(int i=0; i<256; i++)
    {
      MyCube.neoPixelFill((0/10),(i/10),(255/10),true);
      delay(3);
    }
  }
}

void glowLightRandom(int repeat)
{
  int glowRed=0;
  int glowGreen=0;
  int glowBlue=0;
  for(int i=0 ; i<repeat ; i++)
  {
    int Red=random(0,25);
    int Green=random(0,25);
    int Blue=random(0,25);
    for(int i=0; i<25; i++)
    {
      MyCube.neoPixelFill(glowRed,glowGreen,i,true);
      delay(50);
      if(glowRed<Red)
      glowRed++;
      if(glowGreen<Green)
      glowGreen++;
    }
    for(int i=25; i>=0; i--)
    {
      MyCube.neoPixelFill(glowRed,glowGreen,i,true);
      delay(50);
      if(glowRed>0)
      glowRed--;
      if(glowGreen>0)
      glowGreen--;
    }
    Red=random(0,25);
    Blue=random(0,25);
    for(int i=0; i<25; i++)
    {
      MyCube.neoPixelFill(glowRed,i,glowBlue,true);
      delay(50);
      if(glowRed<Red)
      glowRed++;
      if(glowBlue<Blue)
      glowBlue++;
    }
    for(int i=25; i>=0; i--)
    {
      MyCube.neoPixelFill(glowRed,i,glowBlue,true);
      delay(50);
      if(glowRed>0)
      glowRed--;
      if(glowBlue>0)
      glowBlue--;
    }
     Green=random(0,25);
     Blue=random(0,25);
    for(int i=0; i<25; i++)
    {
      MyCube.neoPixelFill(i,glowGreen,glowBlue,true);
      delay(50);
      if(glowGreen<Green)
      glowGreen++;
      if(glowBlue<Blue)
      glowBlue++;
    }
    for(int i=25; i>=0; i--)
    {
      MyCube.neoPixelFill(i,glowGreen,glowBlue,true);
      delay(50);
      if(glowGreen>0)
      glowGreen--;
      if(glowBlue>0)
      glowBlue--;
    }
  }
}

void randomLightShow(int repeat)
{
  for(int i=0; i<repeat ; i++)
  {
    int firstPixel=random(0,149);
    MyCube.neoPixelSetValue(firstPixel,random(0,255),random(0,255),random(0,255),true);
    delay(1);
    MyCube.neoPixelClear();
    delay(1);
  }
}

Credits

DIY GUY Chris

DIY GUY Chris

48 projects • 332 followers
I'm having fun while making electronics projects, I am an electrical engineer in love with "Do It Yourself" tasks.
Thanks to Altium.

Comments