Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Gustavo Reynaga
Published © CC BY-SA

IoT Candle

Beatiful Candle with ESP8266 and WS2811 BreakOut

BeginnerProtip1 hour15,763
IoT Candle

Things used in this project

Hardware components

ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
SparkFun FTDI Basic Breakout - 3.3V
SparkFun FTDI Basic Breakout - 3.3V
×1
SparkFun ws2812b BreakOut
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino core for ESP8266 WiFi chip

Story

Read more

Schematics

IoT Candle

IoT Candle

Code

IoT Candle

Arduino
Enjoy this beatiful IoT Candle
// Source: Tim Bartlett
//https://github.com/timpear
// This turns the animations into functions



#include <Adafruit_NeoPixel.h>
#define PIN 2

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  colorStep(2000); //This calls the colorStep animation, and sends the variable 2000 for delay time
  fader(); //This calls the fader animation
  fadeRepeater(4); //This tells fadeRepeater to happen 4 times
}

void colorStep(int pause) {
  strip.setPixelColor(0, 255, 0, 0);
  strip.show();
  delay(pause);
  strip.setPixelColor(0, 0, 255, 0);
  strip.show();
  delay(pause);
  strip.setPixelColor(0, 0, 0, 255);
  strip.show();
  delay(pause);
  strip.setPixelColor(0, 255, 255, 255);
  strip.show();
  delay(pause);
  strip.setPixelColor(0, 0, 0, 0);
  strip.show();
  delay(pause);
}

void fader() {
  for (int i = 0; i < 255; i++) {
    strip.setPixelColor(0, i, i, 0);
    strip.show();
    delay(4);
  }
  for (int i = 255; i > 0; i--) {
    strip.setPixelColor(0, i, i, 0);
    strip.show();
    delay(4);
  }  
}

void fadeRepeater (int reps) {
  for (int i = 0; i < reps; i++) {
    fader();
  }
}

Credits

Gustavo Reynaga
12 projects • 88 followers
Iam a teacher
Thanks to Tim Bartlett.

Comments