Adafruit is open and shipping! Let's build back better, together!
0

Christmas tree light example code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Christmas tree light example code

by kevinjwalters on Mon Dec 17, 2018 6:02 pm

For anyone with a big PSU and some long (5m) strips of DotStars (or NeoPixels with trivial change), I wrote some code last year to show how they can be used for Christmas tree lights. Originally tested on a Gemma M0 but I'm sure it'll work well on other CircuitPython compatible boards:


** These are a bit naughty/inelegant and break the object encapsulation in the quest for higher performance.

It's best to keep SPI bus physically short and place board in the tree. You can still extend the power if you have cables thick enough for the current.

kevinjwalters
 
Posts: 785
Joined: Sun Oct 01, 2017 3:15 pm

Re: Christmas tree light example code

by adafruit_support_bill on Mon Dec 17, 2018 7:29 pm

Nice work. Thanks for sharing your code!

adafruit_support_bill
 
Posts: 79406
Joined: Sat Feb 07, 2009 10:11 am

Re: Christmas tree light example code

by kevinjwalters on Sat Jan 19, 2019 12:47 pm

A slightly tardy, petit example of dotstar-simple-twinkle.py adapted for Circuit Playground Express's NeoPixels:

minichristmastree-cpxlights-2.gif
Circuit Playground Express used to light a small cardboard Christmas tree from below (low res animated gif)
minichristmastree-cpxlights-2.gif (918.18 KiB) Viewed 227 times


minichristmastree-cpxlights-f392-800px.jpeg
Circuit Playground Express used to light a small cardboard Christmas tree from below (still)
minichristmastree-cpxlights-f392-800px.jpeg (121.03 KiB) Viewed 224 times


This is using CircuitPython 3.1.1. The following diff shows the adaptations needed for the smaller number of onboard NeoPixels:

Code: Select all | TOGGLE FULL SIZE
< import adafruit_dotstar
---
> #import adafruit_dotstar
> import neopixel
43c44
< numpix = 144
---
> numpix = 10
54c55,56
< strip = adafruit_dotstar.DotStar(oclock, odata, numpix, bright, False)
---
> #strip = adafruit_dotstar.DotStar(oclock, odata, numpix, bright, False)
> strip = neopixel.NeoPixel(board.NEOPIXEL, numpix, auto_write=False)
184c186
<     width = random.randrange(3,11,2)  ### odd between 3 and 11
---
>     width = random.randrange(3,7,2)  ### odd between 3 and 7


Other similar projects/code:


kevinjwalters
 
Posts: 785
Joined: Sun Oct 01, 2017 3:15 pm

Re: Christmas tree light example code

by kevinjwalters on Thu Apr 04, 2019 7:33 pm


kevinjwalters
 
Posts: 785
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.