#include "H:\projet PIC\Programme\electro_juin.h"
#ZERO_RAM
#include <stdio.h>
#include <stdlib.h>
#int_RDA
void RDA_isr(void)
{
}
int16 temp,temp1;
void main()
{
setup_adc (ADC_CLOCK_DIV_8);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
setup_psp(PSP_DISABLED);
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);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
set_tris_d(0x00);
while(1)
{
delay_ms (500);
temp=read_adc();
temp1= 5*temp*(100.00/1023.00); <-------CORRECT ?
printf("%2.1f\n\r",(float) temp1);
if(temp1 < 100) //If temperature < 100°C
{
output_high(PIN_d6); //switch on the green led
output_low(PIN_d7); //switch off the red led
}
else
{
output_high(PIN_d7); //switch on the red led
output_low(PIN_d6); //switch off the green led
}
}
}