///////////////////////////////////////
//AUTOR:JORGE ARTURO RODRIGUEZ HERNANDEZ
//TITLE;SENSORES
//DATE:28/AGOSTO/'09
///////////////////////////////////////
//CONFIGURACION///////////////////
#include<16F886.h>
#device ADC=8
#fuses INTRC_IO,NOWDT,NOLVP,MCLR,NOPROTECT
#use delay(clock=8000000)
#include<LCD420_PORTC.C>
#include<kbd_lib.C>
int PLANTA1,PLANTA2,PLANTA3,PLANTA4;
short DONE;
int KEY;
void config(void){
set_tris_a(0x0F);
set_tris_b(0xF0);
port_b_pullups(0xF0);
setup_adc(ADC_CLOCK_INTERNAL|VSS_VDD);
setup_adc_ports(sAN0|sAN1|sAN2|sAN3);
setup_comparator(NC_NC_NC_NC);
disable_interrupts(GLOBAL);
}
void ADC_HECHO(void){
while(DONE!=1){
DONE=adc_done();
}
}
void main(void){
config();
lcd_init();
kbd_init();
START:
lcd_gotoxy(1,1);
lcd_putc("\f------SENSORES------");
lcd_gotoxy(1,2);
lcd_putc("ENTRAR A MEDIR LOS");
lcd_gotoxy(1,3);
lcd_putc("SENSORES:");
lcd_gotoxy(9,4);
lcd_putc("YES(A)");
do{
KEY=kbd_getc();
if(KEY!=0){
if(KEY=='A')
break;
}
}while(TRUE);
lcd_gotoxy(1,1);
lcd_putc("\f------SENSORES------");
do{
set_adc_channel(0);
delay_us(50);
ADC_HECHO();
PLANTA1=read_adc();
set_adc_channel(1);
delay_us(50);
ADC_HECHO();
PLANTA2=read_adc();
set_adc_channel(2);
delay_us(50);
ADC_HECHO();
PLANTA3=read_adc();
set_adc_channel(3);
delay_us(50);
ADC_HECHO();
PLANTA4=read_adc();
PLANTA1=2*PLANTA1;
PLANTA2=2*PLANTA2;
PLANTA3=2*PLANTA3;
PLANTA4=2*PLANTA4;
lcd_gotoxy(1,2);
printf(lcd_putc,"1.- %u C 2.- %u C ",PLANTA1,PLANTA2);
lcd_gotoxy(1,3);
printf(lcd_putc,"3.- %u C 4.- %u C ",PLANTA3,PLANTA4);
KEY=kbd_getc();
if(KEY!=0)
goto START;
}while(TRUE);
}