Ten steps to a sound-activated arduino

User avatar
Soreloser
Posts: 5
Joined: Tue Dec 07, 2010 8:51 pm

Ten steps to a sound-activated arduino

Postby Soreloser » Sat Jul 16, 2011 3:46 am

Last edited by Soreloser on Fri Mar 23, 2012 7:14 pm, edited 1 time in total.

User avatar
Soreloser
Posts: 5
Joined: Tue Dec 07, 2010 8:51 pm

Re: Ten steps to a sound-activated arduino

Postby Soreloser » Sat Jul 16, 2011 5:52 pm

Also, if you wanted to test out different microphones, you'll need some way to find out about how sensitive your other microphones are. That being the case, I put some new code in that will put an average input number on your display so that you have some number to work with.

replace your setup() function with:
void setup() {
slcd.begin();
slcd.backlight();
pinMode(13, OUTPUT);
Serial.begin(9600);
slcd.print("Count:0");
slcd.setCursor(9,0);
slcd.print("avg:");
slcd.setCursor(13,0);
slcd.print(analogRead(input),DEC);
slcd.setCursor(0,1);
slcd.print("Sensitivity:");
slcd.setCursor(12,1);
slcd.print(triggerNumber,DEC);
}

You can also put some parts of this into your doWork() function if you want it to update the average for every trigger. I just haven't found it to be necessary.

Keep in mind that a louder noise will cause the number to drop, therefore, if you want the device to become less-sensitive, you will need to lower the triggerNumber variable.

*Warning* If you update the number every cycle and put it onto the display, you lose valuable "listening" time. You will find that your device will sometimes not trigger when it's supposed to. The idea is to keep the loop() function as free as possible, because it's being continuously run.

User avatar
Awesomeness
Posts: 107
Joined: Thu Dec 02, 2010 7:29 am
Own CNC?: Yes
Location: Colorado
Contact:

Re: Ten steps to a sound-activated arduino

Postby Awesomeness » Sun Jul 17, 2011 6:17 pm

I'm getting an error:

[quote]sketch_jul17a.cpp: In function 'void setup()':
sketch_jul17a:21: error: 'class SerialLCD' has no member named 'backlight'[quote]

When I comment that line out, it works fine, and the backlight is on. What version of the libraries were you using?

User avatar
Awesomeness
Posts: 107
Joined: Thu Dec 02, 2010 7:29 am
Own CNC?: Yes
Location: Colorado
Contact:

Re: Ten steps to a sound-activated arduino

Postby Awesomeness » Sat Jul 23, 2011 2:01 pm


User avatar
Soreloser
Posts: 5
Joined: Tue Dec 07, 2010 8:51 pm

Re: Ten steps to a sound-activated arduino

Postby Soreloser » Sat Sep 03, 2011 11:26 pm

That is an important note. If you change the resistor, the value the int variable "triggerNumber" will need to be changed. If anybody wants this code modified to give you a better idea on what to set "triggerNumber" to be, let me know.

There are a few other things that will affect stable triggering:

-power stability -- When something suddenly drains your home power while your arduino is connected to the computer (air conditioner or heater), it can trigger the sound activation.

-touching the wires -- If the Arduino and/or cables are in your hands, it can just make your device constantly trigger.

User avatar
Soreloser
Posts: 5
Joined: Tue Dec 07, 2010 8:51 pm

Re: Ten steps to a sound-activated arduino

Postby Soreloser » Fri Mar 23, 2012 7:05 pm

Important note: If you're installing the Arduino software for the first time, you will have to replace all instances (in your code) of NewSoftSerial with SoftwareSerial. Also, you will not need to install that software separately. It comes with the Arduino software installation.

It is important. If you do not do that, it will not work.


Return to “Ranger Pop-Up Target System”

Who is online

Users browsing this forum: No registered users and 1 guest