Rev Author Line No. Line
1820 kaklik 1 #include "main.h"
2  
3  
4 void main()
5 {
6  
7 setup_adc_ports(AN0);
8 setup_adc(ADC_CLOCK_DIV_32);
9 setup_psp(PSP_DISABLED);
10 setup_spi(SPI_SS_DISABLED);
11 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
12 setup_timer_1(T1_DISABLED);
13 setup_timer_2(T2_DISABLED,0,1);
14  
15 set_adc_channel(0);
16  
17 while(true)
18 {
19 float humidity;
20 // temperature = ds1820_read();
21 delay_ms(500);
22 humidity=0.14732142 * read_adc() - 22.85714150; //linear interpolation of sensor analog data
23 printf("RH: %f %%\r\n",humidity); //display relative humidity value
24  
25 }
26 }