#include <16f676.h>
#fuses INTRC_IO, NOMCLR, NOWDT, NOBROWNOUT, PROTECT
#use delay(clock=4000000) // Velocidad del reloj : 4 Mhz
#define home_on output_high(PIN_A0); output_high(PIN_A1);
#define home_off output_low(PIN_A0); output_low(PIN_A1);
#define luces_on output_high(PIN_A2); output_high(PIN_C0); output_high(PIN_C1);
#define luces_off output_low(PIN_A2); output_low(PIN_C0); output_low(PIN_C1);
#define contacto PIN_A3
#define cierre PIN_C5
float sensor;
float umbral;
float porcentaje=1.05;
// No puede haber instrucciones que no estén dentro del main o algúna subrutina
void main(){
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(sAN3 | sAN7); // RA4 y RC3 SE CONFIGURAN ASÍ,TAMBIÉN DEPENDE DE LA VERSIÓN DEL COMPILADOR
do{
while(!(input(contacto))){
if(input(cierre)){
home_on;
delay_ms(5000);
home_off;
}
}
while(input(contacto)){
//Lectura del sensor
set_adc_channel(3);
delay_us(6);
sensor=read_adc();
//Lecutra del umbral
set_adc_channel(7);
delay_us(6);
umbral=read_adc();
if(sensor>umbral){
delay_ms(1000);
if(sensor>umbral){
luces_on;
}
}
else if(sensor<((umbral)/(porcentaje))){ // Aquí había un fallo (te faltaba "if")
delay_ms(10000);
if(sensor>((porcentaje)*(umbral))){
luces_off;
}
}
}
}while(TRUE);
}