![]() |
![]() |
#13 |
Đệ tử 2 túi
Tham gia ngày: Jan 2011
Bài gửi: 36
: |
bạn ơi sao mình copi code của bạn để biên dịch ra file hex được rồi mà khi mô phỏng trên protuer nó chẳng ra gì cả??? ko biết protues co bị gì ko mình sử dụng v7.6 SP4???
Code:
#include <16F877A.h> #device *=16 adc=10 #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT #use delay(clock=4000000) #include <lcd.c> #define LCD_DATA_PORT getenv("SFR:PORTD") #define LCD_ENABLE_PIN PIN_D0 //// #define LCD_RS_PIN PIN_D1 //// #define LCD_RW_PIN PIN_D2 #define LCD_DATA4 PIN_D4 //// #define LCD_DATA5 PIN_D5 //// #define LCD_DATA6 PIN_D6 //// #define LCD_DATA7 PIN_D7 //// #byte portB =0x06 //// #bit B1= portB.1 //// #bit B2= portB.2 //// void push_key(void); main() { set_tris_b(0b00000110); port_b_pullups(true); set_tris_c(0b00000000); lcd_init(); lcd_gotoxy(1,1); // cot 1 hang 1 lcd_putc("Menu controler"); lcd_gotoxy(1,2); lcd_putc("K="); while(1) { push_key(); } } void push_key() { int count; if(B1==0) //nut o chan B1 duoc nhan { delay_ms(10); //delay qua xung nhieu while(B1==0) //cho den khi tha {;} count++; //dem so lan bam nut lcd_gotoxy(3,2); lcd_putc(" "); lcd_gotoxy(3,2); Printf(LCD_putc,"%u",count); // hiển thị số count đếm lên LCD delay_ms(10); //delay qua xung nhieu } else if(B2==0) //nut o chan b2 duoc nhan { delay_ms(10); while(B2==0) {;} count--; //dem so lan bam nut lcd_gotoxy(3,2); lcd_putc(" ");// lcd_gotoxy(3,2); Printf(LCD_putc,"%u",count); // hiển thị số count đếm lên LCD delay_ms(10); //delay qua xung nhieu } else { } } |
![]() |
![]() |
|
|