vijaynallasivam
Junior Member level 1
Hi,
i write with c program in hitech compiler below this program was push to on push to off working but if push to switch continuously the output was continuously on & off glow ....how to stop this problem
i write with c program in hitech compiler below this program was push to on push to off working but if push to switch continuously the output was continuously on & off glow ....how to stop this problem
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #include<htc.h> #include<pic.h> #include <delay4.c> #define ON GPIO0==1 #define OFF GPIO0==0 #define _XTAL_FREQ 4000000 __CONFIG(MCLREN & UNPROTECT & BORDIS & WDTDIS & PWRTEN & INTIO); void main() { PIE1=0x00; ANSEL = 0x00; // Set ports as digital I/O, not analog input ADCON0 = 0x00; // Shut off the A/D Converter CMCON = 0x07; // Shut off the Comparator VRCON = 0x00; // Shut off the Voltage Reference TRISIO = 0b000100; GPIO = 0x00; for(;;) { if (GPIO2 == 0 && GPIO0 == OFF) { GPIO0=1; GPIO0 =ON; } if (GPIO2 == 0 && GPIO0 == ON) { GPIO0=0; GPIO0=OFF; } DelayMs(3000); } }