0

CPX/CRICKIT CODING HELP NEEDED
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CPX/CRICKIT CODING HELP NEEDED

by htmagic on Mon May 10, 2021 2:02 pm

Folks,

I have been working with CircuitPython on a CPX/CRICKIT board and have the code almost worked out but need a little help.
I have a 4 channel radio control receiver interfaced with the CPX/CRICKIT IO pins.
Attached is a snippet of the code I'm using.

When I push Button A on the keyfob remote, the CPX/Crickit recognizes this and starts playing Alex.wav.
At the same time, the eyes more back and forth via Servo1 and are supposed to stop on the center.
After Alex.wav, Servo2 activates for 5 seconds and retracts.

My problem is Servo1 does not appear to go to the center (90°) after Alex.wav plays.
So the eyes look like they're looking to the right after the sound stops.

When you hit the next Button, the eyes center again but get stuck off center at the end.

Also, is there a way to define this function and if so, how?
I will probably use this same function for all 4 buttons on the keyfob remote.
I'm not that great at coding yet and muddled around with it with no luck.
Once I get the code working, I might post a YouTube video showing it all in action.

Thank you in advance for reviewing this and responding.
This forum is a great compilation of people more talented than I.
May the FORCE be with you and have a magical day!

MagicBill
Attachments
mod_code2.txt
(3.31 KiB) Downloaded 5 times

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

Re: CPX/CRICKIT CODING HELP NEEDED

by dastels on Mon May 10, 2021 5:35 pm

You break out of the loop that moves the servo back & forth before recentering it. Maybe just move
Code: Select all | TOGGLE FULL SIZE
if (count == 2):
    break

to after
Code: Select all | TOGGLE FULL SIZE
eye_servo.angle = 90
time.sleep(1)


Dave

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

Please be positive and constructive with your questions and comments.