# Logic needed to read and store values

I am new to programming. I have one input signal from waveform generator. I am giving this signal to one sensor and as well as channel 1 of multiplexer. The sensor output is giving to channel 2 of multiplexer. If sensor output is low then I am using some amplification, the signal after amplification is giving to channel 3 of multiplexer. I am using switch case to select one of the input as output of the multiplexer. The multiplexer output is giving to external ADC and I am able to read ADC value.
My problem is I need both sensor input voltage and sensor output voltage for calculating impedance but I have written one function to read ADC values. Is there any possibility to get input and output voltage using same read ADC function and I have to use both voltage values later on. Or I have to write two different read ADC functions to read input and output voltage values. Any advice please.

I am using C language.

Edited: Hi, I am able to read different MUX channels. I am able to select first channel and reading ADC value and stored in a variable. If i change MUX channel to channel 2 and tried to read ADC and stored in another variable. But the problem is when i tried to read second channel, first time it is giving previous channel value and then if i read second time then it is giving second channel actual value. Can any one suggest me how to overcome this. I want to get the original value of that channel first time itself?

I have tried like this.

                          switch(c){

case '1':
PORTB=0x00;
SetWGFreq(arg);
Delay(1000);
Command = 0;
break;

case '2':
PORTB=0x04;
SetWGFreq(arg);
Delay(1000);
Command = 0;
break;
defalut:
command=0;
break;
}


But I have tried to print the ADC value out side the switch case. There it is changing at first time but when i tried to print within switch case I have to enter that case twice.

-
What do you mean by "input voltage" or "output voltage" ? It seams that "input voltage" is from the channel 1 of the MUX and "output voltage" from channel 2 or 3. –  Blup1980 Oct 22 '12 at 13:49