Difference between revisions of "LED Ring NeoPixel"
Jump to navigation
Jump to search
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Description = | = Description = | ||
− | The NeoPixel ring has 3 connections: GND, +/VCC, and the signal. The signal is connected to an output pin and given as parameter (in the example pin 0). The chip to decode the protocol - built into the NeoPixel ring - is WS2812. They are also available in different sizes (more or less LEDs) and different shapes (e.g. band). You have to provide the total number of LEDs as parameter. | + | The NeoPixel ring has 3 connections: GND, +/VCC, and the signal/IN. The signal is connected to an output pin and given as parameter (in the example pin 0). The chip to decode the protocol - built into the NeoPixel ring - is WS2812. They are also available in different sizes (more or less LEDs) and different shapes (e.g. band). You have to provide the total number of LEDs as parameter. |
If you need more than one ring (or other arrangements), you can put them in a row - basically connecting the next ring to the first one (you have to solder it on). | If you need more than one ring (or other arrangements), you can put them in a row - basically connecting the next ring to the first one (you have to solder it on). | ||
Line 8: | Line 8: | ||
= How to connect it electrically = | = How to connect it electrically = | ||
− | + | You can "chain" them. If you only have one ring, just connect GND, VCC, and In. | |
− | + | [[File:Neopixel3.PNG|400px]] | |
+ | |||
+ | [[File:LedRing.PNG|x400px]] | ||
+ | [[File:RingSetup.jpg|x400px]] | ||
= How to control it in MicroPython = | = How to control it in MicroPython = | ||
Line 82: | Line 85: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
− | |||
= Related Tutorial Videos = | = Related Tutorial Videos = |
Revision as of 17:27, 23 March 2022
Contents
Description
The NeoPixel ring has 3 connections: GND, +/VCC, and the signal/IN. The signal is connected to an output pin and given as parameter (in the example pin 0). The chip to decode the protocol - built into the NeoPixel ring - is WS2812. They are also available in different sizes (more or less LEDs) and different shapes (e.g. band). You have to provide the total number of LEDs as parameter.
If you need more than one ring (or other arrangements), you can put them in a row - basically connecting the next ring to the first one (you have to solder it on).
How to connect it electrically
You can "chain" them. If you only have one ring, just connect GND, VCC, and In.
How to control it in MicroPython
1 import neopixel
2 from machine import Pin
3
4 # number of leds
5 n=8
6 # connected Pin
7 p=0
8
9 np = neopixel.NeoPixel(Pin(p),n)
10
11 # sets color of the led at position 0 to (r,g,b)
12 np[0] = (255,0,0)
13 # colors the leds
14 np.write()
A small Program in MicroPython
1 import neopixel
2 from machine import Pin
3 from time import sleep
4
5 # number of leds
6 n=8
7 # connected Pin
8 p=0
9
10 np = neopixel.NeoPixel(Pin(p),n)
11
12 # colors the led at position in (r,g,b)
13 def color(position, r,g,b):
14 np[position]=(r,g,b)
15 np.write()
16
17 # remove all colors
18 def clearAll():
19 for i in range(n):
20 color(i,0,0,0)
21
22 # remove color from led at position
23 def clear(position):
24 color(position,0,0,0)
25
26
27 # the color (r,g,b) should run x times like a cycle
28 def cycle(r,g,b,wait,x):
29 # before setting new colors, clear the ring
30 clearAll()
31
32 # the cycle should run x times
33 for j in range(x):
34 for i in range(n):
35 # clear the previous led
36 if(i==0):
37 clear(n-1)
38 else:
39 clear(i-1)
40
41 # color the current led
42 color(i,r,g,b)
43
44 # wait, color is displayed this time
45 sleep(wait)
46
47
48 cycle(0,255,255,0.5,4)
Related Tutorial Videos
change to the right video
Background
text
image(s)