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!
DIY GUY Chris
Published © Apache-2.0

World's Smallest RGB LED Cube With 384 Pixels

Compact RGB LED Cube with 384 pixels in an 8cm³ design. Powered by ATmega328, WS2812B LEDs. Full tutorial from PCB to assembly.

IntermediateFull instructions provided24 hours1,662
World's Smallest RGB LED Cube With 384 Pixels

Things used in this project

Hardware components

ATmega328
Microchip ATmega328
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Rechargeable Battery, 3.7 V
Rechargeable Battery, 3.7 V
×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

3D Printer (generic)
3D Printer (generic)
Hot Plate, Convection
Hot Plate, Convection
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Paste, Rework
Solder Paste, Rework

Story

Read more

Custom parts and enclosures

Cube assembly aid

Sketchfab still processing.

Schematics

Schematic

Code

Arduino code

Arduino
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif
#define PIN            7
#define NUMPIXELS      384

int Red=0;
int Green=0;
int Blue=0;
Adafruit_NeoPixel MyCube = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


void setup()
{
  MyCube.begin();
  MyCube.setBrightness(10);
  delay(1000);
  for(int j=0; j<100; j++)
  {
    MyCube.setBrightness(j);
    for(int k=0;k<NUMPIXELS;k++)
    {
      MyCube.setPixelColor(k,MyCube.Color(255,30,30));
    }
    MyCube.show();
    delay(1);
  }
  for(int j=100; j>=0; j--)
  {
    MyCube.setBrightness(j);
    for(int k=0;k<NUMPIXELS;k++)
    {
      MyCube.setPixelColor(k,MyCube.Color(255,30,30));
    }
    MyCube.show();
    delay(1);
  }
}

void loop()
{
  MyCube.setBrightness(50);
  discoMode(5);
  MyCube.setBrightness(15);
  glowLightRandom(1);
  delay(random(300,7000));
  randomLightShow(500);
  delay(random(500,8000));
  slideMoveFast(1);
  delay(random(700,3000));
  smoothColorShow(1);
  delay(500);
  
  Red=random(0,255);
  Green=random(0,80);
  Blue=random(0,50);
  for(int j=0; j<100; j++)
  {
    MyCube.setBrightness(j);
    for(int k=0;k<NUMPIXELS;k++)
    {
      MyCube.setPixelColor(k,MyCube.Color(Red,Green,Blue));
    }
    MyCube.show();
    delay(1);
  }
  for(int j=100; j>=0; j--)
  {
    MyCube.setBrightness(j);
    for(int k=0;k<NUMPIXELS;k++)
    {
      MyCube.setPixelColor(k,MyCube.Color(Red,Green,Blue));
    }
    MyCube.show();
    delay(1);
  }
}

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,128);
      for(int i=0; i<3 ; i++)
      {
        for(int k=0;k<NUMPIXELS;k++)
        {
          MyCube.setPixelColor(k,MyCube.Color(colorSetRed,colorSetGreen,colorSetBlue));
        }
        delay(1);
        MyCube.show();
        MyCube.setPixelColor(firstPixel,MyCube.Color(brightnessRed,brightnessGreen,brightnessBlue));
        delay(1);
        MyCube.show();
        MyCube.setPixelColor(firstPixel,MyCube.Color(colorSetRed,colorSetGreen,colorSetBlue));
        delay(1);
        MyCube.show();
      }
    }
  }
}
void smoothColorShow (int repeat)
{
  for(int k=0 ; k<repeat ; k++)
  {
    for(int j=255; j>=0; j--)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(0,255,j));
      }
      delay(3);
      MyCube.show();
    }
    for(int j=0; j<256; j++)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(j,255,0));
      }
      delay(3);
      MyCube.show();
    }
    for(int j=255; j>=0; j--)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(255,j,0));
      }
      delay(3);
      MyCube.show();
    }
    for(int j=0; j<256; j++)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(255,0,j));
      }
      delay(3);
      MyCube.show();
    }
    for(int j=255; j>=0; j--)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(j,0,255));
      }
      delay(3);
      MyCube.show();
    }
    for(int j=0; j<256; j++)
    {
      for(int i=0;i<NUMPIXELS;i++)
      {
        MyCube.setPixelColor(i,MyCube.Color(0,j,255));
      }
      delay(3);
      MyCube.show();
    }
  }
}

void slideMoveFast(int repeat)
{
  for(int i=0;i<NUMPIXELS;i++)
  {
    MyCube.setPixelColor(i,MyCube.Color(0,0,0));
  }
  MyCube.show();
  for(int i=0 ; i<repeat ; i++)
  {
    for(int i=0;i<NUMPIXELS;i++)
    {
      MyCube.setPixelColor(i,MyCube.Color(random(0,255),random(0,255),random(0,255)));
      delayMicroseconds(10);
      MyCube.show();
    }
    
    for(int i=0;i<NUMPIXELS;i++)
    {
      MyCube.setPixelColor(i,MyCube.Color(0,0,0));
      delayMicroseconds(10);
      MyCube.show();
    }
  }
}

void glowLightRandom(int repeat)
{
  int glowRed=0;
  int glowGreen=0;
  int glowBlue=0;
  for(int i=0 ; i<repeat ; i++)
  {
    int Red=random(0,255);
    int Green=random(0,255);
    int Blue=random(0,255);
    for(int i=0; i<255; i++)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(glowRed,glowGreen,i));
      }
      MyCube.show();
      delay(1);
      if(glowRed<Red)
      glowRed++;
      if(glowGreen<Green)
      glowGreen++;
    }
    for(int i=255; i>=0; i--)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(glowRed,glowGreen,i));
      }
      MyCube.show();
      delay(1);
      if(glowRed>0)
      glowRed--;
      if(glowGreen>0)
      glowGreen--;
    }
    Red=random(0,255);
    Blue=random(0,255);
    for(int i=0; i<255; i++)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(glowRed,i,glowBlue));
      }
      MyCube.show();
      delay(1);
      if(glowRed<Red)
      glowRed++;
      if(glowBlue<Blue)
      glowBlue++;
    }
    for(int i=255; i>=0; i--)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(glowRed,i,glowBlue));
      }
      MyCube.show();
      delay(1);
      if(glowRed>0)
      glowRed--;
      if(glowBlue>0)
      glowBlue--;
    }
     Green=random(0,255);
     Blue=random(0,255);
    for(int i=0; i<255; i++)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(i,glowGreen,glowBlue));
      }
      MyCube.show();
      delay(1);
      if(glowGreen<Green)
      glowGreen++;
      if(glowBlue<Blue)
      glowBlue++;
    }
    for(int i=255; i>=0; i--)
    {
      for(int j=0; j<NUMPIXELS; j++)
      {
        MyCube.setPixelColor(j,MyCube.Color(i,glowGreen,glowBlue));
      }
      MyCube.show();
      delay(1);
      if(glowGreen>0)
      glowGreen--;
      if(glowBlue>0)
      glowBlue--;
    }
  }
}

void randomLightShow(int repeat)
{
  for(int i=0; i<repeat ; i++)
  {
    int firstPixel=random(0,384);
    MyCube.setPixelColor(firstPixel,MyCube.Color(random(0,255),random(0,255),random(0,255)));
    delay(1);
    MyCube.show();
    MyCube.setPixelColor(firstPixel,MyCube.Color(0,0,0));
    delay(1);
    MyCube.show();
  }
}

Credits

DIY GUY Chris

DIY GUY Chris

51 projects • 342 followers
I'm having fun while making electronics projects, I am an electrical engineer in love with "Do It Yourself" tasks.

Comments