The following warnings occurred:
Warning [2] Creating default object from empty value - Line: 11 - File: inc/plugins/tapatalk.php PHP 7.4.10 (Linux)
File Line Function
/inc/plugins/tapatalk.php 11 errorHandler->error
/inc/class_plugins.php 38 require_once
/inc/init.php 233 pluginSystem->load
/global.php 18 require_once
/showthread.php 28 require_once
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.4.10 (Linux)
File Line Function
/showthread.php 906 errorHandler->error





Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Analog sound and light detection module
#1
For many robotics projects, the detection of sound and/or light allows your robot to responds to real-life events. And I really wanted to output analog signals, so the program running on the (Arduino?) controller can identify significant signals above the average noise level.

The light part is trivial: By connecting a photo resistor (or LDR: Light Dependent Resistor) R6, in series with a fixed resistor R5, between the supply voltage (+5V) and ground (GND), one can read the voltage over the LDR with an Arduino analog input.

   

For the sound, I used circuits that I found on the web, with some modifications, and the result is shown in the image. The circuit is based on an electret microphone capsule (10 pieces for $1.24 at Aliexpress), a 2N3904 transistor, four resistors, two capacitors, plus a diode. An additional capacitor C1 is used to stabilize the supply voltage. The electret microphone is polarized. It is important to connect that pin to ground which is also connected to its case. The amplifier circuit is made of C1, R2, R3, and T1. The diode clips the negative part of the signal and C2 and R4 form a RC circuit that stores the peaks for a time interval equal to t=R*C, which is 0.01 sec for these choices. The "sound-out" and "light-out" outputs are directly connected to two analog inputs of the Arduino.

The microphone capsule and the photo resistor are soldered on the bottom of the circuit board on a piece of black felt which hides the circuit board through the openings for the microphone and the photo resistor.

   

While I have not finished the Arduino code, this is what I'm planning to do:
Read the sound level every 0.01 sec over an interval of 0.2 sec and store the maximum value of these twenty readings. Use these maxima to compute a rolling average. If the current maximum is significantly larger than the previous average (either: the previous average plus some constant; or the previous average times a fixed factor) then set the "sound detected" trigger.
Reply


Messages In This Thread
Analog sound and light detection module - by Markus - 04-12-2017, 07:19 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)