Using the LM339 to make a discrete selector
While digging around the net, I found several examples that use a LM339 to implement a LED bar graph.
The general circuit is here. Or scroll down a bit to the LED battery meter here.
What I was going for was a linear pot that you could turn to get various modes. By doing this, I could replace a series of switches with one knob. Probably not useful in all situations, but if you had progressive modes or something like a knob that added suboctaves as it turned it might be useful.
It might be even easier to implement as a PIC, but I have not reached that point yet in my sonic explorations. Actually you could do all kinds of things with a linear pot and a PIC, but for now, lets look at the LM339.
The first thing I found out was that it does not drive things well. The LM339 sinks current when it is off. So you need a pull down resistor or something like that.
So this was the basic idea that I wanted to play with. As you turn the knob, more lights light up.
Of course, what fun is it without noise. So I added a clock and a counter to make sound. As each compare circuit is activated, another sub octave is added.

Again, the LM339 really sinks current when its off so you cant really drive LEDS. The output of the NANDs can do it though. The lights are really blinking and not just on. Thats ok.
Here is a sample. Not terribly interesting, but proves the circuit works. Note that the frequency drops a bit with the last octave…hmm…something is drawing too much current. Feel free to improve upon the circuit.
Here is another sample with an LED (and ambient light) driving the LDR in the Oscillators RC loop.
boomp3.com
The final version of this circuit uses only three of the four comparators, but all the inverters in the 40106. Its a circuit with three modes.
The first mode is the simple oscillator putting out a square wave. There is an LDR in the oscillators feedback loop, but the high resistance of the LDR when it is off is in the 1 meg range. As this is parallel to the 100k pot, it has little overall effect. The LDR is glue-gunned (and taped over) to a LED in the LFO section of the circuit.
Mode two activates the LFO. In this mode, it only flashes the LED connected to the LDR so it modulates the frequency.
Mode three allows the output of the LFO to turn on and off the oscillator.
Here is a sample of the circuit.
Some more explanations of the circuit
In mode 0, none of the comparators are one. The most important point in this mode is the NAND (see E). With one of the inputs at low, the signal produced by the oscillator does not get through the and output remains high.
In mode 1, the inputs of the lowest NAND are high(see E) + signal. This results in the signal basically being inverted. The output of the second comparator is low. At point D, the output of the inverter is high. Because of the diode, current is allowed to flow to the capacitor. Once this is charged, it locks the LFO up preventing it from oscillating. The first LED turns on because the current sinks to the inverter and ground. (Hmm…maybe I should have a resistor between the LED and ground…well..whatever.) As was mentioned before, there is an LDR in the RC loop, but since the LED that is attached to it is off, the resistance is much higher that the pot. As these are in parallel, it has little effect.
Example 100k in parallel with 1Meg = (100000*1000000/1100000) = 90.9k (close enough for a noise circuit)

In mode 2, the second comparator turns on. This in turn lowers the voltage at point D. The LFO is now free to oscillate. The LED is gluegunned to the LDR in the oscillator. With the LED on, the LDRs resistance drops to and below the 100k pot. Changing the value of the pot has some effect. An additional 10k resistor was added in series because with the LED on, the frequency shot out of hearing range. Consider a trimpot (or a user pot) there. The second light flashes with the LFO.

In Mode 3, the output of the LFO is allowed to pass its NAND to an inverter and a diode feeding into the oscillator. When the LFO is low, the inverter is HIGH and the oscillator is stopped. This makes for a beep beeping sound. The third LED flashes with the LFO as well.


