I have a few Arduino-based projects which I would like to be able
to respond to sound and/or light. Here is a brief description of my
setup for which the parts cost less than a dollar.
Light
The light part is easy: Connect a photo resistor (or LDR: Light Dependent Resistor) in series with a fixed resistor, between the supply voltage (+5V) and ground (R5 and R6 in the circuit). Then read the voltage over the LDR with an Arduino analog input.
Sound
For the sound recognition, some cheap modules are available, like this one from
Amazon. The disadvantage is, however, that these only provide the digital information whether the sound level is below or above an adjustable, but fixed threshold. For my purposes, I prefer an analog signal, based on which I can compute average values (to take into account the noise level in different situations) and identify significant upwards variations as the signal.
To get an analog signal, 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 microphone capsule and the photo resistor are soldered at the bottom of the circuit board on a piece of black felt, so one can not see the circuit board through the openings for the microphone and the photo resistor. The "sound-out" and "light-out" outputs are directly connected to two analog inputs of the Arduino.