|
Tài trợ cho PIC Vietnam |
Luận văn tốt nghiệp Nếu bạn thắc mắc vì sao chúng tôi muốn phổ biến các luận văn tốt nghiệp? Xin xem tại đây |
|
Ðiều Chỉnh | Xếp Bài |
02-11-2008, 12:51 PM | #6 |
Nhập môn đệ tử
Tham gia ngày: Oct 2008
Bài gửi: 3
: |
mình mới viết được chương trình dùng VDk Pic6f877a. Ở đây mình sử dụng bàn phím để chọn các kiểu sáng của đèn led đơn. Nhằm cho các bạn dễ hiểu. Bài sau mình sẽ post hẳn bài về giao tiếp bàn phím với LCD. Port d bàn phím, Port b điều khiển led.
#include <16F877A.h> #device *16adc=8 #fuses xt,nowdt,nolvp,noprotect #use delay(clock=4000000) #use fast_io(b) void main() { output_b(0b11111111); set_tris_b(0); output_d(0b11111111); delay_ms(10); while(true) { output_d(0b11111110); delay_ms(10); if(input(pin_d4)==0)//nhấn phim1 { while(true) { ////////////// kieu1 output_b(0x7f); delay_ms(150); output_b(0xBf); delay_ms(150); output_b(0xef); delay_ms(150); output_b(0xf7); delay_ms(150); output_b(0xfb); delay_ms(150); output_b(0xfd); delay_ms(150); output_b(0xfe); delay_ms(150); ////////////// output_b(0xfe); delay_ms(150); output_b(0xfd); delay_ms(150); output_b(0xfb); delay_ms(150); output_b(0xf7); delay_ms(150); output_b(0xef); delay_ms(150); output_b(0xbf); delay_ms(150); output_b(0x7f); delay_ms(150); if(input(pin_d5)==0||input(pin_d6)==0||input(pin_d 7)==0) break; } } if(input(pin_d5)==0)//nhấn phím 2 { while(true) { /////////// kieu 2 output_b(0x00); delay_ms(150); output_b(0xff); delay_ms(150); if(input(pin_d4)==0||input(pin_d6)==0||input(pin_d 7)==0) break; } } if(input(pin_d6)==0)//nhấn phím 3 { while(true) { //////////////kieu 3 output_b(0x55); delay_ms(150); output_b(0xaa); delay_ms(150); if(input(pin_d4)==0||input(pin_d5)==0||input(pin_d 7)==0) break; } } if(input(pin_d7)==0)//nhấn phím 4 { while(true) { /////////////kieu 4 output_b(0x7e); delay_ms(150); output_b(0xbd); delay_ms(150); output_b(0xdb); delay_ms(150); output_b(0xE7); delay_ms(150); output_b(0xdb); delay_ms(150); output_b(0xbd); delay_ms(150); output_b(0x7e); delay_ms(150); if(input(pin_d6)==0||input(pin_d4)==0||input(pin_d 5)==0) break; } } } } Bạn nào có thắc mắc liên hệ mình theo địa chỉ này nha: ngochai_dt06b@yahoo.com.vn chuc các bạn thành công với VDK PIC nha. |
|
|
Similar Threads | ||||
Ðề tài | Người gửi | Chuyên mục | Trả lời | Bài mới |
Vì sao nên thảo luận về luận văn tốt nghiệp online? | falleaf | Luận văn tốt nghiệp | 40 | 08-05-2024 08:42 PM |