
Originally Posted by
Melanie
Yes, it could be done... but simplest solution probably requires a little compromise...
First pick a PIC which is more suitable... say a 18F2420... I select this because it has a heap of I/O's and ADC as well. It also has an internal Oscillator so no Xtal or Resonator. Each LED is connected to TWO I/O's through two Resistors. The LED Anode is connected to Vdd, and the Kathode is connected twice... once via one Resistor to one I/O, and a second time via a second Resistor to a second I/O. This arrangement means that with your input into RA0/AN0, you can have eleven LED's connected. Chose a high intensity LED (say with 1300mcd or greater), this means that you can have a decent light output without overloading the PIC when all LEDs are illuminated.
You now have FOUR states for each LED...
OFF = Both I/O's HIGH.
LOW BRIGHTNESS = First I/O is LOW, Second I/O is HIGH (Current flows through R1 - eg 820R).
MED BRIGHTNESS = First I/O is HIGH, Second I/O is LOW (Current flows through R2 - eg 560R).
HIGH BRIGHTNESS = Both I/O's are LOW (Current flow is through both R1 and R2).
The actual Resistor values you will have to chose through experimentation... I just threw those in as a 'best guess'.
This way you have a two-bit digital fadeout (easilly accomplished through software).
If you wish to save a few mA/mW, then HIGH means the PIC pin is in INPUT mode. LOW means it is OUTPUT LOW.
You take say an ADC sample every 500mS. This is your program 'cycle'. Your fade will take four cycles - namely two seconds. If you increase your cycle period, then your fade-out will be quicker. Depending on your ADC Input (max span), your LED's will be illuminated accordingly. At the next cycle, if the ADC value is lower, then the upper LED's are switched into the next level of brightness lower... and so on... simple really...
Each LED is represented as a BYTE in an Array. The BYTE value is between 0 and 3, where 0 is both I/O's for that LED HIGH (LED OFF), and 3 is both I/O's LOW (LED max ON). The good thing is that you can probably feed your (low-level) Audio straight in with a minimum of components, because if say you only have 100mV peak/peak to play with, then you just set your math for ADC span accordingly. Your span (LED switching) range is in software, your Sample & Hold is in software and your fade is in software... what more do you want?
Never mind about LOG, LIN, 3DB points etc etc... this is a light show - not a studio reference instrument!
Cost less than US$10 and an hour of coding.
Bookmarks