ismild
Newbie level 1
stop toggle LED switch 16f877
Hello everyone
I'm beginner for this and sorry for my english language
I need a pic 16f877a program in PIC C Complier
one switch control the led On at time one press
next press the LED will OFF
but my problem is when i press and hold the switch button, it's toggle
" how can i fix this code for stop toggle LED when i press and hold the button "
this is my code
Hello everyone
I'm beginner for this and sorry for my english language
I need a pic 16f877a program in PIC C Complier
one switch control the led On at time one press
next press the LED will OFF
but my problem is when i press and hold the switch button, it's toggle
" how can i fix this code for stop toggle LED when i press and hold the button "
this is my code
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 #include <16F877.h> #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD) #FUSES NOPUT //No Power Up Timer #FUSES NOBROWNOUT //No brownout reset #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O #FUSES NOCPD //No EE protection #FUSES WRT //Program Memory Write Protected #FUSES NODEBUG //No Debug mode for ICD #FUSES NOPROTECT //Code not protected from reading #use delay(clock=20000000) #byte TRISA = 0x85 #byte TRISB = 0x86 #byte PORTA = 0x05 #byte PORTB = 0x06 #bit LED_RED = PORTA.0 #bit PUSH_SWITCH = PORTB.1 void main() { TRISB = 0b00000010; TRISA = 0b00000000; LED_RED = 0; while(TRUE) { if (PUSH_SWITCH == 0) { LED_RED ^= 1; } else { } } }