Wednesday, October 2, 2013
Electronic Ear for Lego RCX Module
The operation of the circuit is simple. IC1, which is wired as a non-inverting amplifier, amplifies the microphone signal by a factor of 100. The output signal from the opamp is rectified by D1 and smoothed by C1. Resistor R2 allows the capacitor to discharge. The resulting DC voltage drives IC2, which acts as a buffer. The output of this opamp is connected to the sensor input of the RCX via a 1-kΩ resistor (R1). Just as with the analogue input adapter described elsewhere in this website, the RCX sees a variable resistance value at the sensor input, and it converts this into a measurement value between 0 and 100.
In the idle state, when no sound is sensed, the measurement value lies between 90 and 100. The louder the sensed sound, the lower the measurement value. You can use the light-sensor routine of the Lego software to set the responses to various sound levels. If you use a threshold value of around 85, then a level under 85 will be sensed as a sound signal, while a level above 85 will be sensed as silence. If you clap your hands near the sensor, the circuit will detect this. If you use these ‘observations’ to increment a counter, it is even possible to measure the number of sound pulses within a defined interval, and then to carry out some action based on the result.