Tom2
Full Member level 5
setup_timer_2();
I wrote a code for a 4 way switch as is show in picture below.The problem is that the circuit is not working.Is anyone who know what is the problem????(i used pcm compiler and pic16f777 microcontroller)
the code is :
if ((input(PIN_A3)==0)) { // if A3 is low
setup_timer_2(T2_DIV_BY_1, 255,1);
output_high(PIN_D2);
}
else if (((input(PIN_A3)==0))&& (input(PIN_A4)==0)) { // if A_4 is low
setup_timer_2(T2_DIV_BY_4, 255,1);
output_high(PIN_D3);
}
else if (((input(PIN_A3)==0) && (input(PIN_A4)==0)&&(input(PIN_A5)==0))) { // if A_5 is low
setup_timer_2(T2_DIV_BY_16, 255,1);
output_high(PIN_C4);
}
else if (((input(PIN_E0)==0)&&(input(PIN_A3)==0) && (input(PIN_A4)==0)&&(input(PIN_A5)==0))) { // if
setup_timer_2(T2_DISABLED , 255,1);
}
I wrote a code for a 4 way switch as is show in picture below.The problem is that the circuit is not working.Is anyone who know what is the problem????(i used pcm compiler and pic16f777 microcontroller)
the code is :
if ((input(PIN_A3)==0)) { // if A3 is low
setup_timer_2(T2_DIV_BY_1, 255,1);
output_high(PIN_D2);
}
else if (((input(PIN_A3)==0))&& (input(PIN_A4)==0)) { // if A_4 is low
setup_timer_2(T2_DIV_BY_4, 255,1);
output_high(PIN_D3);
}
else if (((input(PIN_A3)==0) && (input(PIN_A4)==0)&&(input(PIN_A5)==0))) { // if A_5 is low
setup_timer_2(T2_DIV_BY_16, 255,1);
output_high(PIN_C4);
}
else if (((input(PIN_E0)==0)&&(input(PIN_A3)==0) && (input(PIN_A4)==0)&&(input(PIN_A5)==0))) { // if
setup_timer_2(T2_DISABLED , 255,1);
}