Music Equalizer Display: Software

Program Download:

Main C File
Music_Eq.c

The Software
           The IR range software for this project has two main portions to it.
    -A/D Conversion
    -LED Output Control


A/D Conversion Code

------------« Begin Code »------------
..
..
OpenADC( ADC_FOSC_32
          & ADC_RIGHT_JUST
          & ADC_1ANA_2REF,
          ADC_CH0 & ADC_INT_OFF );
..
..
..
..
..
ConvertADC();
while( BusyADC() );
          result = ReadADC();
..
..
..
------------« End Code »------------

           This code enables the AN0 analog input with AN2 & AN3 as the VREF- & VREF+. Then at the bottom the A/D conversion happens. The lower portion of the code is stuck within the forever while loop so that the led's can constantly be refreshed with a new A/D value.

Led Output Control
------------« Begin Code »------------
while(1)
{
if(result >= 920)
       PORTBbits.RB7 = 1;
else
       PORTBbits.RB7 = 0;
if(result >= 818)
       PORTBbits.RB6 = 1;
else
       PORTBbits.RB6 = 0;
if(result >= 716)
       PORTBbits.RB5 = 1;
else
       PORTBbits.RB5 = 0;
..
..
//ADC Happens
//Re-Loop
..
}
------------« End Code »------------

           The 10-Bit ADC is broken up into 10 areas for each led. If the ADC result is larger than that led's specific value then it is turned on. If it is smaller, the led is turned off. The leds are refreshed every 0.2 mS

           So now that you have the software all coded, program it onto the PIC and let's go see how well it works!



;