|
|
View previous topic :: View next topic |
Author |
Message |
UnLiMiTeD!!!
Joined: 04 May 2011 Posts: 2
|
How to use two ADC inputs? [Solved] |
Posted: Wed May 04, 2011 7:49 am |
|
|
Hello,
I have problem about using two different adc inputs. I dont know how to sepret it, i need to read value from one input, and after that from other one. But with this code: Code: | int a,b;
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
// TODO: USER CODE!!
while(1)
{
set_adc_channel(2);
a = read_adc();
set_adc_channel(3);
b = read_adc();
output_b(a);
output_c(b);
}
} |
I have problem what two values comes together.
It will be great if anyone can help.
thanks |
|
|
UnLiMiTeD!!!
Joined: 04 May 2011 Posts: 2
|
|
Posted: Wed May 04, 2011 7:57 am |
|
|
I solve the problem, its need just to put delay here is the code Code: | #use delay(clock=4000000)
int a,b;
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
// TODO: USER CODE!!
while(1)
{
set_adc_channel(2);
delay_us(20);
a = read_adc();
set_adc_channel(3);
delay_us(20);
b = read_adc();
output_b(a);
output_c(b);
}
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|