AZ-Delivery
Published © GPL3+

An atmospheric angel lamp with WS2812 on ESP8266

We are building an atmospheric angel lamp using a WS2812 neopixel ring, paired with an ESP8266, to create a stunning light display.

BeginnerFull instructions provided278
An atmospheric angel lamp with WS2812 on ESP8266

Things used in this project

Hardware components

ESP32 Dev Kit C unsoldered
or ESP32 Dev Kit C V4 unsoldered or ESP32 NodeMCU Module WLAN WiFi Development Board with CP2102 or NodeMCU-ESP-32S-Kit or ESP32 Lolin LOLIN32 WiFi Bluetooth Dev Kit or NodeMCU Lua Amica Module V2 ESP8266 ESP-12F WIFI Wifi Development Board with CP2102 or D1 MiniNodeMcu with ESP8266-12F WLAN Module compatible with Arduino or D1 Mini V3 NodeMCU with ESP8266-12F
×1
RGB LED ring 8 bit WS2812 5050 + integrated driver
×1
Battery Expansion Shield 18650 V3 incl. USB cable
×1
Li-Po battery type 18650
×1
MB-102 Breadboard plug-in board with 830 contacts
×1
Jumper wire cable 3 x 40 pcs. 20 cm each M2M/ F2M / F2F
×1
Logic Analyzer
optional
×1
White paper 160 to 250 g/m² or tracing paper DIN A4 format
×1

Software apps and online services

Thonny
or µPyCraft
Saleae Logic 2
MicropythonFirmware Download
v1.19.1 (2022-06-18) .bin

Story

Read more

Schematics

Angel Template

Code

Here is the entire program whose elements we have just discussed.

MicroPython
# soft_angel.py
#
# Pintranslator fuer ESP8266-Boards
#LUA-Pins     D0 D1 D2 D3 D4 D5 D6 D7 D8 RX TX
#ESP8266 Pins 16  5  4  0  2 14 12 13 15  3  1
#                 SC SD
# Achtung      hi       hi hi         lo hi hi
# used                        NE

from machine import Pin
from time import sleep_ms
import neopixel
from sys import exit

# An Pin GPIO14 liegt ein 12-er Neopixelring
noc = 12
n=neopixel.NeoPixel(Pin(14),noc)

rt =(255,0,0)
gn =(0,255,0)
bl =(0,0,255)
ge =(255,255,0)
cy =(0,255,255)
pu =(255,0,255)
ws =(255,255,255)
sw =(0,0,0)

debug = False
colors =(rt,ge,gn,cy,cy,bl,pu,pu,ws,sw)
colnames = ("rt","ge","gn","cy","cy","bl","pu","pu","ws","sw")
steps = 64
step = 256 // steps
delay = 25 # ms

while 1:
    try:
        for i in range(len(colors)):
            col1=colors[i]
            name1=colnames[i]
            k=i+1
            k = k % len(colors)
            col2 = colors[k]
            name2=colnames[k]
            if debug: print(i,k,name1,name2)
            
            for j in range(steps):
                color=[0,0,0]
                
                for c in range(3):
                    if col1[c] == col2[c]:
                        color[c] = col1[c]
                    elif col1[c] < col2[c]:
                        color[c] = col1[c] + j * step
                    else :
                        color[c] = col1[c] - j * step
                if debug: print(color,col1,col2)   
                for i in range(12):
                    # fill Buffer
                    n[i] = color
                # Update the strip.
                n.write()
                sleep_ms(delay)
    except KeyboardInterrupt:
        n.buf = bytearray( (0,0,0) * noc)
        n.write()
        print("Programm abgebrochen")
        exit()

Credits

AZ-Delivery
21 projects • 3 followers
We are "AZ-Delivery - Your Expert for Microelectronics". Visit our shop with regularly new Blogs and free E-Books.
Contact

Comments

Please log in or sign up to comment.