This little project is just for fun. I had 3 goals:
- Spend time with the kids
- Learn about RISC-V and the E310 SoC
- Learn about Neopixels
My daughter inspired all the color streams in the project. I am but an implementer of her vision.
Learning about RISC-V and Neopixels had been on the TODO list for too long.
Checkout this movie of the project in action:
All in all, totally fun project. Enjoy!
This is a demo of driving a meter long Neopixel LED strip using the GPIO controller on a HiFive1 evaluation board. The SoC on this board is a SiFive Freedom E310.
First you need to install the Freedom-E-SDK as described here. Build it from source or install pre-built binaries.
Next edit config.mk
and set the SDKDIR
variable to where you
installed the SDK.
This demo uses a meter long Neopixel LED strip, like this one from Adafruit.
I followed this guide to connect the LED strip to a power supply.
Connect the positive lead of the LED strip to PIN-8 on the HiFive1 and
the negative lead to a ground. This is defined in the code
neopixel.c
and the constant NEO_GPIO
.
Just type make software
to compile the code.
Connect your HiFive1 to the host computer in the usual way and type
make upload
. That should upload the code.
Press the reset button on the HiFive1. You will see some debug printouts on the serial console and the LED strip should start dancing.
You might need to adjust the timing constants slightly for your LED
strip. See these constants in neopixel.c
:
/*
* These are the timing constraints taken mostly from the WS2812
* datasheets. These are chosen to be conservative and avoid problems
* rather than for maximum throughput.
*/
#define T1H 700 // Width of a 1 bit in ns
#define T1L 600 // Width of a 1 bit in ns
#define T0H 400 // Width of a 0 bit in ns
#define T0L 900 // Width of a 0 bit in ns
#define RES 7000 // Width of the low gap between bits to cause a frame to latch