unsigned int temp_res; oldstate; i;
void main() {
TRISA = 0xFF;
TRISD = 0b00000000;
PORTD= 0b00000000;
while(1)
{
//temp_res = ADC_Read(0); //
read status of a Pin
if (temp_res) {open();}
else {close();}
}
}
void open(void)
{
unsigned int count=0;
while(count<1000)
{
PORTD=0b00000001;
delay_us(1500);
PORTD=0b00000000;
delay_us(1000);
count++;
}
}
void close(void)
{
unsigned int count=0;
while(count<1000)
{
PORTD=0b00000001;
delay_us(2000);
PORTD=0b00000000;
delay_us(2000);
count++;
}
}