Hi there,
(long-ish post)
I was gifted a Circuit Playground Express and am hoping to execute a homemade stuffed animal project using CircuitPy with the CPX as a device that when shook, will play a wav file.
I am very confused about going about this. I have followed tutorials and successfully accomplished playing a wav. file when button A is pressed, but I do not understand how to incorporate the code to detect shake to then play the wav. file.
Is code to be constantly added to a single code.py file on the CPX? If so, what is mandatory to be included at the top of the code (i.e. import cpx, import time, etc) to ensure that any command I attempt to write can be accomodated?
I believe a problem may be related to the libraries or lack of libraries I am able to add to my CPX? I can add the 6.3.0.uf2 file but when I try to add the corresponding library bundle to the cpx, I get a dialogue box that there is insufficient room on the CPX to hold the entire lib. I have tried formatting the CPX and reapplying the uf2 file and bundle but continue recieving a error of not enough space.
If anyone can blow my mind and point me in a direction of "here is what always needs to be in your code" or what absolutely positively is the only way to load a library, I would so greatly appreciate it. I feel like I have exhausted all the resources on adafruilt.com and I find myself going in circles.
Thank you to everyone and anyone who is willing to assist me. I hope I've made sense and apologize in advance for if I haven't.
-Ant
noob - attempting to write code
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: noob - attempting to write code
In order to save space you need to load .mpy (compiled programs) rather than .py. You might want to follow some tutorials for a simple install before trying to bodge together your own.
- jerryn
- Posts: 1890
- Joined: Sat Sep 14, 2013 9:05 am
Re: noob - attempting to write code
If you are using the 6.0.3 version of CircuitPython, then you should use the 6.x library bundle from here https://circuitpython.org/libraries
However, you should NOT copy the entire bundle to the CPX. That used to be possible, but the bundle has grown loo large.
Unzip the bundle and copy only the libraries that you actually need to the CPX. That process is described in this guide https://learn.adafruit.com/welcome-to-c ... -libraries
There is a lot more information about using CircuitPython on the CPX in this guide https://learn.adafruit.com/circuitpytho ... ss-library
Edited to add:
I took a look at the CPX configuration for CircuitPython and the libraries needed for basic operations are already "built-in" to the loaded image so you may not need to copy any libraries to it to detect shake and play your wav file.
From the CircuitPython configuration , the following libraries are "built-in"
I hope that helps
Note: I do not represent Adafruit, Just trying to help.
However, you should NOT copy the entire bundle to the CPX. That used to be possible, but the bundle has grown loo large.
Unzip the bundle and copy only the libraries that you actually need to the CPX. That process is described in this guide https://learn.adafruit.com/welcome-to-c ... -libraries
There is a lot more information about using CircuitPython on the CPX in this guide https://learn.adafruit.com/circuitpytho ... ss-library
Edited to add:
I took a look at the CPX configuration for CircuitPython and the libraries needed for basic operations are already "built-in" to the loaded image so you may not need to copy any libraries to it to detect shake and play your wav file.
From the CircuitPython configuration , the following libraries are "built-in"
Code: Select all
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
Note: I do not represent Adafruit, Just trying to help.
Please be positive and constructive with your questions and comments.