0

Circuit Playground Examples don't run
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Circuit Playground Examples don't run

by msgeer on Tue Jan 14, 2020 1:22 pm

Hi folks,
I have a Circuit Playground Express that currently does nothing interesting. I'm trying to code in Python. I have loaded it with Circuit Python, the version 4 libraries (all of them) and it correctly shows at CIRCUITPY in Windows. I'm using the Mu editor. I can get it to blink the d13 light, but that's it. I've tried tons of the examples downloaded with the libraries, but nothing has worked. They pass the check in Mu, save correctly to the CPX and I get the steady green on light that means they're running.

I've tried clearing it out and redoing everything - no change. I've tried programming it with MakeCode instead - works fine. I've followed the same process on another CPX - also doesn't work.

It's certainly something I'm missing, but what??

ETA:
Ok, I got some of the examples to run, which supports that it's not the board. Now I find that none of the examples labeled circuitplayground will run. They all have the "from adafruit_circuitplayground import cp" line which generates the error "no module named adafruit_circuitplayground.cp" which is true. But what should it be? Are there other examples somewhere? Or does anyone know what that should read? I tried express (since that's in the lib folder titled adafruit_circuitplayground) instead of cp with no change.

msgeer
 
Posts: 3
Joined: Tue May 23, 2017 1:52 pm

Re: Circuit Playground Examples don't run

by msgeer on Tue Jan 14, 2020 2:43 pm

Ok, I maybe figured it out, but I figured I'd leave the post in case it helps someone else.

The examples use "from adafruit_circuitplayground import cp" but it should read "from adafruit_circuitplayground.express import cpx" and then all references need to change from cp to cpx. So far so good. Hope this helps someone else!

msgeer
 
Posts: 3
Joined: Tue May 23, 2017 1:52 pm

Re: Circuit Playground Examples don't run

by adafruit_support_carter on Tue Jan 14, 2020 3:55 pm

You may just need to update your library version. The way the imports work was changed at version 4.0.0:
https://github.com/adafruit/Adafruit_Ci ... /tag/4.0.0
The examples were changed to match that. So if you are using new examples with old library, it won't work.

adafruit_support_carter
 
Posts: 14033
Joined: Tue Nov 29, 2016 2:45 pm

Re: Circuit Playground Examples don't run

by msgeer on Tue Jan 14, 2020 4:41 pm

A good thought, but the download for version 4 that you linked is what I was using. The library is adafruit_circuitplayground.express but the examples don't have the .express part.

msgeer
 
Posts: 3
Joined: Tue May 23, 2017 1:52 pm

Re: Circuit Playground Examples don't run

by adafruit_support_carter on Tue Jan 14, 2020 4:53 pm

Correct. The libraries have been updated to use the new import syntax. The old syntax also still works. What does not work is to try the new import syntax with an older version of the library. If you are getting an error with this:
Code: Select all | TOGGLE FULL SIZE
from adafruit_circuitplayground import cp

then it seems like you have an older version of the library.

What happens if you try this simple test at the REPL?
Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 4.1.2 on 2019-12-18; Adafruit CircuitPlayground Express with samd21g18
>>> from adafruit_circuitplayground import cp
>>>

adafruit_support_carter
 
Posts: 14033
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.