Introduction
Chances are, you might have seen one of those super cool and flashy Nanoleaf light panels in IKEA or on Amazon. They are a brilliant source of indoor lighting that adds character to a room, with aesthetics that you just can't achieve with a simple light bulb. They are even able to be voice-controlled via amazon Alexa or Google Assistant, etc.
In this Raspberry Pi guide, we'll show you how to build a mini replica of the Nanoleaf. To keep it all as compact as possible, we've chose to use the Raspberry Pi Zero W for this project. However, you can use other models of the Raspberry Pi with it by creating a larger enclosure. This is an intermediate project as you'll need basic soldering skills, as well as access to a 3D printer to create the enclosure for our replica. This guide continues on from our starter guide on TrinityPixel LED strips and Raspberry Pi.Â
Complete this guide to create your own Nanoleaf replica with the Raspberry Pi.Â
In this Raspberry Pi guide, we'll show you how to build a mini replica of the Nanoleaf. To keep it all as compact as possible, we've chose to use the Raspberry Pi Zero W for this project. However, you can use other models of the Raspberry Pi with it by creating a larger enclosure. This is an intermediate project as you'll need basic soldering skills, as well as access to a 3D printer to create the enclosure for our replica. This guide continues on from our starter guide on TrinityPixel LED strips and Raspberry Pi.Â
Complete this guide to create your own Nanoleaf replica with the Raspberry Pi.Â
Tools
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
import time import board import neopixel # Choose an open pin connected to the Data In of the LED strip, i.e. board.D18 # The LED strip must be connected to D10, D12, D18 or D21 to work. pixel_pin = board.D18 # The number of LEDs num_pixels = 9 # The order of the pixel colors - RGB or GRB. Some LEDs have red and green reversed! # For RGBW LEDs, simply change the ORDER to RGBW or GRBW. ORDER = neopixel.GRB pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=1, auto_write=False, pixel_order=ORDER) def wheel(pos): # Input a value 0 to 255 to get a color value. # The colours are a transition r - g - b - back to r. if pos < 0 or pos > 255: r = g = b = 0 elif pos < 85: r = int(pos * 3) g = int(255 - pos*3) b = 0 elif pos < 170: pos -= 85 r = int(255 - pos*3) g = 0 b = int(pos*3) else: pos -= 170 r = 0 g = int(pos*3) b = int(255 - pos*3) return (r, g, b) if ORDER == neopixel.RGB or ORDER == neopixel.GRB else (r, g, b, 0) def rainbow_cycle(wait): for j in range(255): for i in range(num_pixels): pixel_index = (i * 256 // num_pixels) + j pixels[i] = wheel(pixel_index & 255) pixels.show() time.sleep(wait) while True: # Comment this line out if your LED strips are RGBW/GRBW pixels.fill((255, 0, 0)) # Uncomment this line if you have RGBW/GRBW LED strips # pixels.fill((255, 0, 0, 0)) pixels.show() time.sleep(1) # Comment this line out if you have RGBW/GRBW LED strips pixels.fill((0, 255, 0)) # Uncomment this line if you have RGBW/GRBW LED strips # pixels.fill((0, 255, 0, 0)) pixels.show() time.sleep(1) # Comment this line out if you have RGBW/GRBW LED strips pixels.fill((0, 0, 255)) # Uncomment this line if you have RGBW/GRBW LED strips # pixels.fill((0, 0, 255, 0)) pixels.show() time.sleep(1) rainbow_cycle(0.001) # rainbow cycle with 1ms delay per step
-
-
-