CircuitPython NeoPixel Guide

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ZippyFace
 
Posts: 5
Joined: Fri May 22, 2020 5:59 pm

CircuitPython NeoPixel Guide

Post by ZippyFace »

I haven't used Adafruit products or programmed in CircuitPython before.

I'm trying to follow the guide at this link: https://learn.adafruit.com/adafruit-gem ... neopixel-2 to control a series of NeoPixels on a strip but I cannot get the LEDs to light up like they should.

I've taken these steps to set up my board and try to run the code:
1. Downloaded the latest drivers for my board (GEMMA MO)
2. Downloaded and installed the latest CircuitPython so my computer recognizes my board as CIRCUITPY when I plug it into the USB drive
3. Successfully ran the sample code given here: https://learn.adafruit.com/adafruit-gem ... iting-code to verify that I can control the LED mounted on the board
4. Downloaded the latest library bundle and placed the necessary library file (neopixel.mpy) into the lib folder on my board
5. Pasted the sample code from the guide in the first link above for controlling the NeoPixel strip into Mu and saved it to my board
6. Used alligator clips to connect a section of 8 LEDs from a NeoPixel stip to the GEMMA as shown on the circuit diagram given in the guide

Obviously, I've done something wrong or missed a step but I've reviewed the setup steps multiple times and I can't seem to figure this out. Perhaps I just need to restart the process from scratch.

Any advice?

Thank you in advance!

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: CircuitPython NeoPixel Guide

Post by adafruit_support_carter »

5. Pasted the sample code from the guide in the first link above for controlling the NeoPixel strip into Mu and saved it to my board
What filename did you use here?

User avatar
ZippyFace
 
Posts: 5
Joined: Fri May 22, 2020 5:59 pm

Re: CircuitPython NeoPixel Guide

Post by ZippyFace »

The filename I used was NeoPixelDemo.py

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: CircuitPython NeoPixel Guide

Post by adafruit_support_carter »

To have the program run automatically, you'll need to give it one of these names:
https://learn.adafruit.com/welcome-to-c ... 2977482-35

User avatar
ZippyFace
 
Posts: 5
Joined: Fri May 22, 2020 5:59 pm

Re: CircuitPython NeoPixel Guide

Post by ZippyFace »

Thank you, I don't know how I missed that. After using the correct filename, the lights still do not light up. the onboard LED flashes green, then yellow once, then there's a space, then blue 4 times. I looked at the troubleshooting page for GEMMA MO but this sequence of flashes doesn't seem to indicate a line in my code. Also, I copied the code from the tutorial page.

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: CircuitPython NeoPixel Guide

Post by adafruit_support_carter »

That sounds like it might be one of these status indicator patterns?
https://learn.adafruit.com/welcome-to-c ... 2978455-20

User avatar
ZippyFace
 
Posts: 5
Joined: Fri May 22, 2020 5:59 pm

Re: CircuitPython NeoPixel Guide

Post by ZippyFace »

Thank you for your response. After reading your post, I spent more time trying to understand the RGB status light. The link you sent me states

"Colors with multiple flashes following indicate a Python exception and then indicate the line number of the error. The color of the first flash indicates the type of error"

And then it says that a green flash indicates an indentation error. But, as I purposefully put errors in my code to see how it changed the flashes, I realized that the first green flash must indicate that code is running but doesn't indicate an error. After realizing that, I could see that the other flashes I was getting (yellow followed by four cyan) indicate "other error" on line 4 of my code. Line 4 is:

import neopixel

I'm confused why this line is returning an error because I already put the neopixel.mpy file in my lib folder on the GEMMA MO. I'm confident that I downloaded the correct library for my version of CircuitPython. Could there be another reason this line is giving me an error?

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: CircuitPython NeoPixel Guide

Post by adafruit_support_carter »

To get a better read out of the error, try running things interactively via REPL (the CircuitPython prompt). Click the Serial button and then in the lower window, get to the >>> prompt and then try the import statement:
serial_test.jpg
serial_test.jpg (56.13 KiB) Viewed 270 times

User avatar
ZippyFace
 
Posts: 5
Joined: Fri May 22, 2020 5:59 pm

Re: CircuitPython NeoPixel Guide

Post by ZippyFace »

Thank you, that helps. The serial console helped me figure out the issue. There is another library needed to run the code in the tutorial I was following but it isn't specified in the instructions (https://learn.adafruit.com/adafruit-gem ... neopixel-2). The additional library file that is needed is adafruit_pypixelbuf.mpy. It is used by the neopixel.mpy library.

The code works after copying adafruit_pypixelbuf.mpy to the GEMMA lib folder. Thanks again!

User avatar
adafruit_support_carter
 
Posts: 29483
Joined: Tue Nov 29, 2016 2:45 pm

Re: CircuitPython NeoPixel Guide

Post by adafruit_support_carter »

Cool. Glad that worked.

That Serial window trick is useful for helping figure out what is going on. Another way it might have worked would be to have it opened while your code ran. In the screen shot above, you can see it says:

Code: Select all

code.py output:
and then the results of the code running. In that example it isn't too exciting. But it would have also printed the text of the error message when it happened.

Have fun!

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”