Arnov Sharma
Published © GPL3+

3D-Printed Nanoleaf ATtiny85

A cheap DIY version of Nanoleaf RGB LIGHT with ATtiny85 and WS2812 RGB strip.

BeginnerFull instructions provided3 hours11,275
3D-Printed Nanoleaf ATtiny85

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
Arduino UNO
Arduino UNO
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
everything above can be found here for a low price
×1
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

stl files

nanoleaf_body_RRYBolgZhQ.stl

Schematics

sch

Code

code

C/C++
#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   1 
#define PIXEL_PIN    0   // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 12 //change this number to whatever rgb you are using

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW) {
      showType++;
      if (showType > 14)
        showType=0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  oldState = newState;
}


void startShow(int i) {
  switch(i){
    case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
            break;
    case 1: colorWipe(strip.Color(255, 0, 0), 50);  // Red
            break;
    case 2: colorWipe(strip.Color(0, 255, 0), 50);  // Green
            break;
    case 3: colorWipe(strip.Color(0, 0, 255), 50);  // Blue
            break;
    case 4: colorWipe(strip.Color(100, 0, 255), 50);  // purp 
            break;            
    case 5: colorWipe(strip.Color(200, 0, 255), 50);  // lite purp
            break;             
    case 6: colorWipe(strip.Color(255, 0, 100), 50);  // pink
            break;  
    case 7: colorWipe(strip.Color(255, 255, 0), 50);  // yellown
            break;
    case 8: colorWipe(strip.Color(255, 110, 20), 50);  // orange
            break;
    case 9: colorWipe(strip.Color(255, 100, 100), 50);  // Rorange
            break;
    case 10: colorWipe(strip.Color(255, 180, 40), 50);  // lite orange 
            break; 
    case 11: colorWipe(strip.Color(0, 255, 255), 50);  // LIGHT Blue
            break;                                                   
    case 12: colorWipe(strip.Color(0, 255, 100), 50); //greenish blue 
            break;
    case 13: colorWipe(strip.Color(150, 255, 0), 50);  //greenish red 
            break;
    case 14: colorWipe(strip.Color(255, 255, 255), 50);  // white
            break; 
  }
}


void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}



// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 1, 0, WheelPos * 1);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 1, 255 - WheelPos * 1);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 1, 255 - WheelPos * 1, 0);
}

Credits

Arnov Sharma

Arnov Sharma

269 projects • 275 followers
Just your average MAKER

Comments