Magic cube with Led strip light

Just read OP, he’s using WS2801 strip, which is 5050 RGB, they are rated 12V, with max draw of 20mA per colour.

Excuse me, I was thinking the ws2812b …

But still, if you measure it, you know for sure :slight_smile:

1 Like

Hello sir
Am using the WS2801 which has data clock and -+
Am powering the 24 leds from the 5v pin at the wemos d1 mini
Before I install it I checked the amps when is it not fully color it not drawing a lot of amps just 0.2
When I choice the patterns it’s just drawing 0.5 amps
And less
It’s been on 24/7 never turned off and still it’s in very good condition working .
What kind of strip u wanna use I’ll try to help u out
Thanks

1 Like

Hi @dananmo I am going to use ws2812b strip which I think is just the same. Do you have a copy of your code the cube is actually running and could you paste it here ???

Cheers

Kev

Sure I have copy and I’ll post it as soon as am home

thanks man that would be really useful

Cheers

Kev

hello here is the code
just coz am using WS2801 so i had to add CLOCK PIN and
here i had to add the CLOCK PIN also

  FastLED.addLeds<LED_TYPE, DATA_PIN,CLOCK_PIN, LED_ARRANGE>(leds, LED_NUMBER);

in ur case u dont need it just coz u have just ± DATA PIN
so u will have just DATA PIN D2
and

  FastLED.addLeds<LED_TYPE, DATA_PIN, LED_ARRANGE>(leds, LED_NUMBER);

.
this is the rest of the code

#define BLYNK_PRINT Serial
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastLED.h>
#include <SimpleTimer.h>
//#include <wifi_credentials.h>
//#include "settings.h"
/**************************************************************

                            Settings

 **************************************************************/
/*
   Blynk Auth Code
*/
#define AUTH                        "xxxxx"
/*
   WS28xx Config
*/

#define LED_TYPE                    WS2801
#define LED_ARRANGE                 GRB
#define LED_NUMBER                  24
#define LED_LIMIT_MILLIAMPS         2000 // Limit current in mA (Must be using FastLED v3.1.1+)
/*
    Zone - Assign a zone to your hardware
    --------------------------------------
      In the Blynk App, fill out the Menu Widget at the top with the different
      zones you want to control.
      Typically this is each room or area so you can control the entire
      zone at once, and exclude other zones. Example below:
        Zone 0 = reserved (will return nothing as its a false)
        Zone 1 = reserved (to control "all" zones at once)
        Zone 2 = Office  (Menu Widget Item 1)
        Zone 3 = Lounge  (Menu Widget Item 2)
        Zone 4 = Outside (Menu Widget Item 3)
        etc.. you can go until your menu widget doesnt let you add more.
    --------------------------------------
*/
//#define ZONE                        2
#define ZONE                        3
/*
    Nickname - Unique name for each node
    --------------------------------------
      Typically this would be the zone name, followed by the node number.
      In my home, I have 2 nodes in each room. So I call them OFFICE1, OFFICE2, LOUNGE1, LOUNGE2.
    --------------------------------------
*/
//#define NICKNAME                    "Swimming_Pool"
#define NICKNAME                   "Magic Cube"
/*
   --------------------------------------
   Over The Air Hostname

     I try to use the NICKNAME (above) as the name to identify it in the IDE.
     Althought you can use what ever you like.
   --------------------------------------
*/
//#define OTA_HOSTNAME                "LED-Swimming_Pool"
#define OTA_HOSTNAME                "Magic Cube"
/*
   Local Server Settings (uncomment to use local server)
*/
//#define USE_LOCAL_SERVER
//#define SERVER                      IPAddress(192, 168, 1, 2)
#define BLYNK_MSG_LIMIT             400
/*
   Hardware Pins
*/
#define DATA_PIN                    D2// GPIO12 / D6 on WeMos/NodeMCU ESP8266
//#define CLOCK_PIN                    D8
/*
   Virtual Pins
*/
#define vPIN_HUE                    V0
#define vPIN_SATURATION             V1
#define vPIN_BRIGHTNESS             V2

#define vPIN_PRESET                 V3

#define vPIN_FPS                    V5

#define vPIN_COLOUR_BLUE            V4
#define vPIN_COLOUR_RED             V6
#define vPIN_COLOUR_GREEN           V7
#define vPIN_COLOUR_WHITE           V8

#define vPIN_TERMINAL               V9
#define vPIN_MANUAL                 V10
#define vPIN_SYNC_GHUE              V11
#define vPIN_TEST                   V12

#define vPIN_ALERT                  V13
#define vPIN_OFF                    V14

#define vPIN_RAINBOWSPEED           V22
#define vPIN_ZONE_SELECT            V23
#define vPIN_TESTMODE               V24

#define vPIN_COLOUR_MEM1            V25
#define vPIN_COLOUR_MEM2            V26
#define vPIN_COLOUR_MEM3            V27
#define vPIN_COLOUR_MEMSAVE         V28

#define vPIN_NIGHTMODE              V29
/*

*/



int varSpeed, varRainbowSpeed, varAlertMode, varZone;
int testLEDnumber, varMemSave;
int arrayCurrent[5], arrayMemory1[5], arrayMemory2[5], arrayMemory3[5], arrayNightMemory[5];

WidgetTerminal terminal(vPIN_TERMINAL);
SimpleTimer timer;
CRGB leds[LED_NUMBER];

void setup() {
  WiFi.mode(WIFI_STA);
  Serial.begin(115200);

 Blynk.begin(AUTH, "USERNAME", "PASSWORAD");
//#endif
  while (Blynk.connect() == false) {}
  /*********** OTA *************/
  ArduinoOTA.setHostname(OTA_HOSTNAME);
  ArduinoOTA.begin();
  /******** BOOT VARS **********/
  arrayCurrent[0, 255, 255, 255]; // Set starting sequence as rainbow mode
  varSpeed = 100; // Start on 100 fps
  varZone = 1;
  varRainbowSpeed = 0;    // Start stationary
  /******** FASTLED ************/
#ifdef LED_LIMIT_MILLIAMPS
  FastLED.setMaxPowerInVoltsAndMilliamps(5, LED_LIMIT_MILLIAMPS);
#endif
  FastLED.addLeds<LED_TYPE, DATA_PIN,CLOCK_PIN, LED_ARRANGE>(leds, LED_NUMBER);
  /******** READY **************/
  terminal.print(F("# Blynk v" BLYNK_VERSION ": "));
  terminal.print(NICKNAME);
  terminal.println(F(" Device started"));
  terminal.flush();
}

// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns

String CurrentHexRGB() {
  return String("#") + String(((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b, HEX);
}

BLYNK_WRITE(vPIN_HUE) {
  if (varZone == ZONE || varZone == 1) {
    updateColours(arrayCurrent[0], param.asInt(), arrayCurrent[2], arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
  }
}
BLYNK_WRITE(vPIN_SATURATION) {
  if (varZone == ZONE || varZone == 1) {
    updateColours(arrayCurrent[0], arrayCurrent[1], param.asInt(), arrayCurrent[3]);
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
  }
}
BLYNK_WRITE(vPIN_BRIGHTNESS) {
  if (varZone == ZONE || varZone == 1) {
    updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], param.asInt());
    //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
  }
}
BLYNK_WRITE(vPIN_FPS) {
  if (varZone == ZONE || varZone == 1) varSpeed = param.asInt();
}
BLYNK_WRITE(vPIN_PRESET) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) nextPattern();
}
BLYNK_WRITE(vPIN_COLOUR_RED) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    updateColours(1, 96, 255, 255);
    updateWidgets();
  }
  
}
BLYNK_WRITE(vPIN_TEST) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) gCurrentPatternNumber+1;
  
}
BLYNK_WRITE(vPIN_COLOUR_GREEN) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    updateColours(1, 0, 255, 255);
    updateWidgets();
  }
}
BLYNK_WRITE(vPIN_COLOUR_BLUE) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    updateColours(1, 159, 255, 255);
    updateWidgets();
  }
}
BLYNK_WRITE(vPIN_COLOUR_WHITE) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    updateColours(1, 255, 0, 255);
    updateWidgets();
  }
}
BLYNK_WRITE(vPIN_MANUAL) {
  if (varZone == ZONE || varZone == 1) {
    updateColours(param.asInt(), arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
    updateWidgets();
  }
}
BLYNK_WRITE(vPIN_SYNC_GHUE) {
  gHue = 0;
  varSpeed = 100;
  terminal.print(NICKNAME);
  terminal.println(" | Sync'd gHUE ");
  terminal.flush();
}
BLYNK_WRITE(vPIN_ALERT) {
  varAlertMode = param.asInt();
}
BLYNK_WRITE(vPIN_OFF) {
  if ( varZone == ZONE || varZone == 1 && param.asInt()) {
    updateColours(1, 255, 255, 0);
    updateWidgets();
  }
}
BLYNK_WRITE(vPIN_RAINBOWSPEED) {
  if ( varZone == ZONE || varZone == 1) {
    varRainbowSpeed = param.asInt();
    Blynk.virtualWrite(vPIN_RAINBOWSPEED, varRainbowSpeed);
  }
}
BLYNK_WRITE(vPIN_ZONE_SELECT) {
  varZone = param.asInt();
  if (varZone == ZONE) {
    terminal.print(NICKNAME);
    terminal.println(" | Zone Selected!");
    terminal.flush();
    updateColours(arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
    Blynk.virtualWrite(vPIN_FPS,  varSpeed);
    Blynk.virtualWrite(vPIN_RAINBOWSPEED, varRainbowSpeed);
  }
}
BLYNK_WRITE(vPIN_COLOUR_MEM1) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    if (varMemSave) {
      arrayMemory1[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
      Blynk.setProperty(vPIN_COLOUR_MEM1, "color", CurrentHexRGB());
    } else {
      updateColours(arrayMemory1[0], arrayMemory1[1], arrayMemory1[2], arrayMemory1[3]);
      updateWidgets();
    }
  }
}
BLYNK_WRITE(vPIN_COLOUR_MEM2) {
  if (varZone == ZONE || varZone == 1 && param.asInt()) {
    if (varMemSave) {
      arrayMemory2[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
      Blynk.setProperty(vPIN_COLOUR_MEM2, "color", CurrentHexRGB());
    } else {
      updateColours(arrayMemory2[0], arrayMemory2[1], arrayMemory2[2], arrayMemory2[3]);
      updateWidgets();
    }
  }
}
BLYNK_WRITE(vPIN_COLOUR_MEM3) {
  if ( varZone == ZONE || varZone == 1 && param.asInt()) {
    if (varMemSave) {
      arrayMemory3[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
      Blynk.setProperty(vPIN_COLOUR_MEM3, "color", CurrentHexRGB());
    } else {
      updateColours(arrayMemory3[0], arrayMemory3[1], arrayMemory3[2], arrayMemory3[3]);
      updateWidgets();
    }
  }
}
BLYNK_WRITE(vPIN_COLOUR_MEMSAVE) {
  varMemSave = param.asInt();
}
BLYNK_WRITE(vPIN_TESTMODE) {
  if (param.asInt()) {
    updateColours(2, arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
    testLEDnumber = param.asInt();
  } else {
    updateColours(0, arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]);
  }
}
BLYNK_WRITE(vPIN_NIGHTMODE) {
  if (param.asInt()) {
    arrayNightMemory[arrayCurrent[0], arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]];
    updateColours(1, 152, 255, 100);
    updateWidgets();
  } else {
    updateColours(arrayNightMemory[0], arrayNightMemory[1], arrayNightMemory[2], arrayNightMemory[3]);
    updateWidgets();
  }
}
void updateColours(int m, int h, int s, int b) {
  arrayCurrent[0] = m;
  arrayCurrent[1] = h;
  arrayCurrent[2] = s;
  arrayCurrent[3] = b;
}
void updateWidgets() {
  Blynk.virtualWrite(vPIN_MANUAL,     arrayCurrent[0]);
  Blynk.virtualWrite(vPIN_HUE,        arrayCurrent[1]);
  Blynk.virtualWrite(vPIN_SATURATION, arrayCurrent[2]);
  Blynk.virtualWrite(vPIN_BRIGHTNESS, arrayCurrent[3]);
  //Blynk.setProperty(vPIN_HUE, "color", CurrentHexRGB());
}

/****************************************************************************/
void loop(){
  Blynk.run();
  ArduinoOTA.handle();
  timer.run();

  switch (varAlertMode) {
    case 1:
      for (int i = 0; i < 20; i++) {
        fill_solid(leds, LED_NUMBER, CRGB::White);
        FastLED.show();
        delay(50);
        fill_solid(leds, LED_NUMBER, CRGB::Black);
        FastLED.show();
        delay(50);
      }
      varAlertMode = 0;
      break;
    case 2:
      for (int i = 0; i < 5; i++) {
        fill_solid(leds, LED_NUMBER, CRGB::White);
        FastLED.show();
        delay(250);
        fill_solid(leds, LED_NUMBER, CRGB::Black);
        FastLED.show();
        delay(50);
        fill_solid(leds, LED_NUMBER, CRGB::White);
        FastLED.show();
        delay(50);
        fill_solid(leds, LED_NUMBER, CRGB::Black);
        FastLED.show();
        delay(250);
      }
      varAlertMode = 0;
      break;
    case 3:
      for (int i = 0; i < 10; i++) {
        fill_solid(leds, LED_NUMBER, CRGB::Blue);
        FastLED.show();
        FastLED.delay(50);
        fill_solid(leds, LED_NUMBER, CRGB::Red);
        FastLED.show();
        FastLED.delay(50);
      }
      varAlertMode = 0;
      break;
    case 4:
      for (int i = 0; i < 10; i++) {
        fill_solid(leds, LED_NUMBER, CRGB::Red);
        FastLED.show();
        FastLED.delay(50);
        fill_solid(leds, LED_NUMBER, CRGB::Black);
        FastLED.show();
        FastLED.delay(50);
      }
      varAlertMode = 0;
      break;
  }

  switch (arrayCurrent[0]) {
    case 1:
      fill_solid(leds, LED_NUMBER, CHSV(arrayCurrent[1], arrayCurrent[2], arrayCurrent[3]));
      break;
    case 2:
      FastLED.clear();
      for (int led = 0; led < testLEDnumber; led++) leds[led] = CRGB::Blue;
      break;
    default:
      gPatterns[gCurrentPatternNumber]();
      EVERY_N_MILLISECONDS( 20 ) gHue++;  // slowly cycle the "base color" through the rainbow
      break;

  }
  FastLED.show();
}
/****************************************************************************/
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern() {
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE(gPatterns);
}

void rainbow() {
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, LED_NUMBER, gHue, varRainbowSpeed);
  FastLED.delay(1000 / varSpeed);
}

void rainbowWithGlitter() {
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) {
  if ( random8() < chanceOfGlitter) leds[ random16(LED_NUMBER) ] += CRGB::White;
  FastLED.delay(1000 / varSpeed);
}

void confetti() {
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, LED_NUMBER, 20);
  int pos = random16(LED_NUMBER);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
  FastLED.delay(1000 / varSpeed);
}

void sinelon() {
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, LED_NUMBER, 10);
  int pos = beatsin16(13, 0, LED_NUMBER);
  leds[pos] += CHSV( gHue, 255, 192);
  FastLED.delay(1000 / varSpeed);
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, LED_NUMBER, 20);
  byte dothue = 0;
  for ( int i = 0; i < 8; i++) {
    leds[beatsin16(i + 7, 0, LED_NUMBER)] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
  FastLED.delay(1000 / varSpeed);
}

am also like u sir i try to do my best to make it work
if u have any improvments ill be very happy to see it ,
also looking forward to see ur project
thank u
also all the V PINS i had to add it in the code coz i wasnt able to add the file in the library
if u need any help ill be happy to help u :slight_smile:

1 Like

Cheers @dananmo I will let you know how I get on with it

How did you stick the whole cube together - did you just glue the plexiglas to the wood ?

Also what diameter hole is in the middle and what size is the cube itself ?

Cheers

Kev

The size of the cube I had wood laying around its 8x8 .,
And either u can use the wood glue or epoxy
I used wood glue and let it set for one day .
But before u stick the plexi make sure u sand it both faces so the light will reflect more inside .
The hole is 3" I had holesaw after u glue all of it in the end sand it and make all the surface equals then u can stain it or laker it .
The last layer which is the base don’t glue it i case u want to trouble shoot it in future .
Thanks

1 Like