0

on loud sound trigger repeats
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

on loud sound trigger repeats

by jakel on Thu Oct 29, 2020 5:07 pm

I am attempting to program my CPx to respond to a loud noise by activating attached neopixel flora and move a servo (making a spider jump and shine red eyes).

The code I am using works. However, multiple loud noises are triggering the CPx and the lights stay on and the servo essentially freezes. When I put the delay at the end, it just stores the action and repeats after the delay. Is there a way to turn off the sensor for a period of time, for example for 7 seconds. Is this a form of debounce? code is below.

One additional question. In order to trouble-shoot I created the blocks for the neopixel and the servo in separate programs. I did not see a way to cut and paste blocks from two different programs, so I redid the block code. Is there an easier way?

circuitplayground-screenshot-4.png
snapshot
circuitplayground-screenshot-4.png (437.51 KiB) Viewed 171 times

jakel
 
Posts: 14
Joined: Sun Sep 02, 2012 7:35 pm

Re: on loud sound trigger repeats

by gbertoia on Fri Oct 30, 2020 12:14 am

Not sure about the servo issue but have copied blocks from one program to another by switching to Javascript copying that code then going to other program switching to javascript and pasting the javascript then switch back to blocks.

gbertoia
 
Posts: 3
Joined: Mon May 30, 2016 2:09 am

Re: on loud sound trigger repeats

by jakel on Fri Oct 30, 2020 5:05 pm

@gbertoia
Thanks. Yah, that is the workaround I try and use for transferring code. Not knowing Java I have a hard time with incorporating it. You make a good point, if copying blocks isn't available, it is worth learning enough Java to switch over the code. Just wish it was circuit python, which I am trying to learn.

Any ideas out there regarding my Servo question?

jakel
 
Posts: 14
Joined: Sun Sep 02, 2012 7:35 pm

Please be positive and constructive with your questions and comments.