Br ght Wearables

BRIGHTLY FAQ

About Brightly

The BRIGHTLY code editor

Using BRIGHTLY CircuitPython code with LEDs

***About***

What is BRIGHTLY?
Brightly is a CircuitPython code generator for programmable LEDs (NeoPixels). It is based on Blockly, an open-source, drag and drop code editor. BRIGHTLY lets you drag and drop simple code blocks to generate a CircuitPython program that shows different colors, patterns and animations on an LED string. This is not a professional product. It is a project I created to help with my programming workshops, which I decided to share, hoping others will find it useful. Standard disclaimer here.

What makes BRIGHTLY useful?
Brightly lets you generate interesting dynamic patterns for LED strips with a minimum amount of work. It is a particularly useful tool for a non programmer. When coding in Python, correct formatting is critical - an errant space or missing colon crashes a program. Using BRIGHTLY to generate the CircuitPython code avoids formatting pitfalls, and is simply much faster than writing code manually.

What will I need to run a BRIGHTLY generated program on a microcontroller?
You'll need a microcontroller which runs CircuitPython that is connected to a strip of Neopixels on one pin. You will need the Adafruit CircuitPython NeoPixel library from the CircuitPython Bundle. You will also need to download the BRIGHTLY CircuitPython library and copy it to your board. See the BRIGHTLY Instructions page for details on what to do with the libraries to make sure your code will run.

Why did you create BRIGHTLY?
I wanted to run a programmable LED wearables workshop for non-programmers, and let the participants change the colors and patterns on their creations. Some of the more advanced easy-to-use microcontroller boards (BBC micro:bit, Adafruit CircuitPlayground Express) have a powerful drag-and-drop programming interface through MS MakeCode, which works well for novice programmers. However,  the cheaper CircuitPython controllers (e.g. Adafruit's Gemma M0 and Trinket M0) which are ideal for workshops, have no such interface, so I thought I'd create one.

Can BRIGHTLY program electronic accessories other than LEDs?
No. The BRIGHTLY code generator is strictly for creating LED pattens and animations. You can run the BRIGTHLY functions along with other CircuitPython libraries that control sensors and elctronics, but you will need to modify Brightly's generated code to do so.

What microcontrollers does BRIGHTLY work on?
So far, I have tested it on Adafruit's Gemma M0, Trinket M0 and CircuitPlayground Express. It should run on any CircuitPython-enabled microcontroller that can use Adafruit's Neopixel library to connect to programmable LED strings.

How can I find out more about CircuitPython?
A good place to start is this article: https://learn.adafruit.com/welcome-to-circuitpython/what-is-circuitpython

I found a bug. Whom should I notify?
Please send bug reports to brightly@brightwearables.com.I can't guarantee a timely fix, but will try to maintain the code editor. If you would like to try to fix the problem yourself (or make an improvement), the source code for the BRIGHTLY code generator is here: https://github.com/BrightWearables/blockly-brightly

***The BRIGHTLY code editor***

How do I use the code editor?
BRIGHTLY will be familliar to anyone who has done drag and drop programming. The code blocks, which represent LED colors, patterns or functions, are categorized into different menus on the left side of the window, called the toolbox. Just click on a category to view its blocks. To create code, drag the blocks from the menu into the workspace, and place them within one of the existing green blocks ("run once at start" or "run forever") to add them to your program. It should be intuitve that function blocks placed inside the "run once" block will run one time when the program starts (i.e. the microcontroller is powered on or restarted), and function blocks placed inside the "run forever" block will run over and over again in a loop. You will probably want to put most of your program in the "run forever" block.

Brightly Code Generator

How do I get CircuitPython code from my BRIGHTLY block program?
Once you have written your program, click the purple "Download Code" link, and a file named "main.py" containing CircuitPython code will download to your computer.

Can I save my BRIGHTLY program?
Yes, if you want to save your BRIGHTLY code blocks, enter a file name in the "Save Blocks to File" field, and click "Save as XML". This will download an XML file to your computer which contains instructions to generate the BRIGHTLY program in the BRIGHTLY code editor. The XML file is NOT a CircuitPython program, and will not run on a microcontroller.

How do I edit a BRIGHTLY program I previously created?
As long as you saved your program as an XML file, you can load it into the BRIGHTLY editor by clicking the "Choose File" link at the top of the window. BRIGHTLY cannot read CircuitPython files, only XML files generated from the BRIGHTLY code generator.

Can I use BRIGHTLY to edit CircuitPython code directly?
No. BRIGHTLY can only edit code blocks saved in XML files.

Why does the BRIGHTLY code editor default to using 14 LEDs?
Because I developed it for a workshop making a programmable LED headband that has (surprise!) 14 LEDs (https://www.youtube.com/watch?v=JadMgPY26nA). However, you can easily change the number of LEDs by clicking the dropdown menu in the "run once at start" code block.

***Using BRIGHTLY CircuitPython code with LEDs***

What kind of LEDs can I program with BRIGHTLY?
BRIGHTLY is designed for single-wire control RGB WS2812-type LED strips and strings - (aka NeoPixels), because it depends on Adafruit's CircuitPython NeoPixel library. These LEDs are easily available from a wide variety of sources. BRIGHTLY will not work with APA102-type LED strips (also known as Dotstar).

Does BRIGHTLY have a maximum number of LEDs?
Currently the number of LEDs in the BRIGHTLY code editor is capped at 36 because some code blocks expand as the number of LEDs grows, and it becomes awkward to drag and drop them inside the workspace. If I find a way to make the code blocks for large number of LEDs less unwieldy, then this will change. However, another limit to the number of LEDs comes from memory limitations on CircuitPython boards. CircuitPython itself requires a lot of memory to run and on smaller boards (Gemma M0 and Trinket M0) this can limit code size and available memory. On boards with more memory, this is not nearly as much of a problem. I have encountered no problems creating fairly large programs for strings of 14 LEDs. A new generation of CircuitPython boards based on the ATSAMD51 chip will have more memory, so hardware will probably solve this problem in the future.

How do I make my BRIGHTLY CircuitPython program run on my microcontroller?
Please see the Instructions page for details

What if I have RGBW LEDs instead of RGB LEDs. Will they work?
Yes. There is no place to change the type of LED in BRIGHTLY itself, but if you open up the "main.py" file and find the function call which creates the NeoPixel strip:

    strip = neopixel.NeoPixel(board.D1, numpix, brightness=0.2, auto_write=False, pixel_order=None)

you can change the code to work with different kinds of LEDs by changing the word "None" to one of (RGB, GRB, RGBW, GRBW) - whichever maches your strip.

DISCLAIMER

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)

HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

(back to top)