Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Circuit Playground Express Cricket Hardware
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Circuit Playground Express Cricket Hardware

by htmagic on Mon Jun 22, 2020 10:17 am

Folks,

I recently got a Circuit Playground Express Cricket and wish to do something similar to John Parks The Scream Painting.
I managed to load the UF2 file to the unit and his code and am having issues.
The /lib folder on the PYDRIVE is empty. Not sure why.
I managed to get the unit to make a noise, and the servo jiggled a little as well but it's not consistent.
Late last night I was getting I2C errors when I was fiddling with it. I will probably wipe all the software and reinstall.
Do I need to add an extra libraries? It talked about v 4.X and I saw v 5.X and installed that. I may try v 4.X and see if I can get that to work.

But my question is, instead of the microphone, I wish to trigger the painting with a 2 channel radio control (RC) unit to activate 2 separate servos.
How do I tie in a receiver such as this?
https://www.adafruit.com/product/1097

Can I do it through the capacitive touch pins or do I use the IO pins on the Cricket?
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Mon Jun 22, 2020 10:28 am

You need to copy the libraries (aka modules in Python) that you want to use into the lib directory. Don't try to copy the entire bundle, there isn't room. Just copy the ones you need for what you're working on.

Use the latest version (non-beta) of 5.x and get the 5.x module bundle.

If you are using the crickit, be sure to get the CircuitPlaygroundExpress+Cricit CircuitPython UF2 file. It has the crickit related libraries "baked in" so you won't need to copy those to the lib directory.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Mon Jun 22, 2020 10:50 am

Dave,

I understood the v 5.X had some libraries "baked in". That's why I used it instead of v 4.X.
But what about the RC receiver?
How do I tie that into the Cricket?
I'm using a toggle type receiver, i.e., one push of Button A turns on the channel, another push turns it off.
The little video shows 4 LEDs with dropping resistors to each of the 4 channel outputs.
I'm using a 2 button remote so I only need to worry about D0 and D1 pins.
I can handle the 5V and GND pins, what is the VT pin?
So can I just port the D0 and D1 pins to the IO pins on the Cricket?

Thanks again for all your help.
I have learned quite a bit from studying your posts.
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Mon Jun 22, 2020 1:40 pm

Sorry... I totally missed the questions at the end.

To use that receiver, just wire the output pins (D0 & D1) to signal inputs on the Crickit. Then poll them via the Crickit library.

So you are on the right track. From the look of the datasheet (which is pretty sparse in explanation) I think you can ignore VT.

You don't need to worry about pullups on the inputs since they are being connected to a logic output and not a switch.
You *may* (I can't confirm as I don't have the receiver board) need a level shifter since the receiver is 5v logic and the signal inputs on the crickit are 3.3v logic.

I hope that helps.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by dastels on Mon Jun 22, 2020 2:25 pm

I tried an experiment applying 0v and 5v to the crikit signal inputs and it read fine as false and true, respectively.

So a level shifter is not needed.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Mon Jun 22, 2020 2:41 pm

Dave,

Thank you so much!
I may pick your brain about polling the Cricket for those signals when I get back in town this weekend.
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Mon Jun 22, 2020 3:14 pm

Of course.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Mon Jun 22, 2020 9:44 pm

David,

I figured out the issue I had with the Circuit Playground Express Crickit Hardware.
I needed to upload the latest Crickit seesaw firmware as explained here:
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit/update-your-crickit
Once I updated the firmware to the Crickit Hat, the scream code worked!
I need to resolder the speaker as the wires came loose.

Now I tried it again but it won't work the 2nd time.
I get this from the serial:

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
File "code.py", line 7, in <module>
File "adafruit_crickit.py", line 396, in <module>
RuntimeError: SDA or SCL needs a pull up

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit CircuitPlayground Express with Crickit libraries with samd21g18
>>>

Once the code loads consistently, then I'd like to modify it and add the 2nd servo.
The 1st servo will also activate back and forth but slower.
Thanks again for your awesome help!
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Mon Jun 22, 2020 10:16 pm

Try completely disconnecting power and then reconnect. This problem pops up every now and then.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Mon Jun 22, 2020 10:33 pm

Dave,

I reset the power on the Crickit Hat and reloaded the seesaw firmware.
Now it samples the mic and the plotter works as well.
I set the threshold to 500 instead of 1000.
Eventually, I want to eliminate the mic and use the IO from the RC unit.

For servo 1, I want to move the servo back and forth for about a minute.
I also want servo 1 to move back and forth slower, so I modified these lines:

else:
print("LOUD")
head_servo.angle = 60
time.sleep(.7505)
head_servo.angle = 120
time.sleep(.7505)
head_servo.angle = 90
time.sleep(.502)
head_servo.angle = 60
time.sleep(.7505)
head_servo.angle = 120
time.sleep(.7505)
head_servo.angle = 90
time.sleep(.502)
head_servo.angle = 60
time.sleep(.7505)
head_servo.angle = 120
time.sleep(.7505)
head_servo.angle = 90
time.sleep(.502)
play_file("scream_low.wav")
head_servo.angle = 90
time.sleep(2)

Is there a more elegant way of doing this? I will not use the scream_low.wav file and will replace it with something else.
I may even decide not to use a wav file at all so the audio portion may be eliminated.

Thanks in advance for your help.
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Wed Jun 24, 2020 10:42 am

I suggest you read through this series: https://learn.adafruit.com/multi-tasking-the-arduino-part-1.

The code is C++, but the concepts translate directly to CircuitPython.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Wed Jun 24, 2020 1:02 pm

Dave,

Thank you very much!
I will study and learn this.
I was looking for a simple do loop to repeat the actions. I just copied the code and piggybacked it onto what was already written.
It worked but I realized it's sloppy code.
I don't know much about C++ but will study and get up to speed on it.

Thanks again for your help.
I was able to get the Scream code to work. Now I need to change it to fit my needs.
And I learned quite a bit in the process.
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Wed Jun 24, 2020 1:25 pm

Enjoy the learning process!

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Re: Circuit Playground Express Cricket Hardware

by htmagic on Wed Jun 24, 2020 2:36 pm

Dave,

I scanned some of it already.
Unfortunately, my servos will do different things.
Servo1 will move back and forth, similar to John Parks the Scream painting albeit a lot slower.
Servo1 will shift eyes on a painting back and forth, back and forth as if he is looking around.
Servo 2 will move 90° or so and stop. It will hold that position for 10-15 seconds and slowly retract.
So each servo will have a different program on it and I can't really group them to do the same action.

But I will continue to study. Is there a tutorial on how to use the IO ports on the Crickit hat?
I will want to marry my RC receiver to the hat to trigger the servos. I will not even use the mic for input anymore after that.
And I am not sure if I want my painting to "speak" yet.
And the beauty with the Crickit hat, if I want the eyes to light, it has neopixel outputs I could use.
Again, thank you for your answers.
May the FORCE be with you and have a magical day!

MagicBill

htmagic
 
Posts: 34
Joined: Tue Dec 03, 2013 12:18 am

Re: Circuit Playground Express Cricket Hardware

by dastels on Wed Jun 24, 2020 3:11 pm

Have a look in the main Crickit guide, epecifically https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit/circuitpython-signals.

There's no need to group the servos together. Each will have it's own update sequence, and times when they should update. I advise reading through the entire series, then experiment.

Dave

dastels
 
Posts: 3519
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.