PIC Vietnam

Go Back   PIC Vietnam > Ban Điều Hành > Đóng góp ý kiến

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Tìm Kiếm Bài Trong Ngày Ðánh Dấu Ðã Ðọc Vi điều khiển

Đóng góp ý kiến Nơi tiếp nhận những ý kiến đóng góp của thành viên

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 08-12-2015, 09:38 PM   #14
saubeo6600
Nhập môn đệ tử
 
Tham gia ngày: Jun 2009
Bài gửi: 1
:
Huong Dan code pic 16f877a

Mình là dân tay ngang nhưng đam mê điện tử, mình mới tìm hiểu lập trình pic một thời gian, nhưng chưa đủ trình độ để hiểu chương trình này, xin mọi người giúp đỡ giải thích những dòng lệnh dưới đây, hoặc trong file đính kèm.Xin cám ơn rất nhiều. Mình có một ý tưởng để giúp đỡ ba mẹ đỡ nhọc nhằn, chỉ cần hiểu được code này mình tin sẽ lam được!

#include <16F877A.h>
#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
int1 gt1, gt2, gt3, gt4;
char num=0,val=0;
char read_BCD()
{
if(input(PIN_A0))val |= 0x01;
if(input(PIN_A1))val |= 0x02;
if(input(PIN_A2))val |= 0x04;
if(input(PIN_A3))val |= 0x08;
return(val);
}
void kiemtra1()
{
gt1 = INPUT(pin_c0);
if(gt1==1)
{
output_high(pin_d0);
delay_ms(200);
output_low(pin_d0);
delay_ms(50);
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);}
if(gt1==0)
{
output_high(pin_d0);
delay_ms(200);
output_low(pin_d0);
delay_ms(50);}
}
void kiemtra2()
{
gt2 = INPUT(pin_c1);
if(gt2==1)
{
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
delay_ms(50);
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
}
if(gt2==0)
{
output_high(pin_d0)
;delay_ms(100);
output_low(pin_d0);
delay_ms(50);
}
}
void kiemtra3()
{
gt3 = INPUT(pin_c2);
if(gt3==1)
{ output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
delay_ms(50);
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);}
if(gt3==0)
{
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
delay_ms(50);
}
}
void kiemtra4()
{
gt4 = INPUT(pin_c3);
if(gt4==1)
{
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
delay_ms(50);
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
}
if(gt4==0)
{
output_high(pin_d0);
delay_ms(100);
output_low(pin_d0);
delay_ms(50);}
}
void main()
{
int1 m=1;
set_tris_a(0xFF);
set_tris_c(0xff);
set_tris_d(0x00);
set_tris_b(0b00000001);
output_b(0x00);
output_d(0x00);
while(true)
{
if((input(PIN_B0))&&(m==1))
{
num=read_BCD();
val=0;m=0;
}
if((input(PIN_B0))==0)m=1;
switch(num)
{
case 0:break;
case 1:
{
output_toggle(PIN_B1);
num=0;
break;
}
case 2:
{
output_toggle(PIN_B2);
num=0;
break;
}
case 3:
{
output_toggle(PIN_B3);
num=0;
break;
}
case 4:
{
output_toggle(PIN_B4);
num=0;
break;
}
case 5:
{
kiemtra1();
num=0;
break;
}
case 6:
{
kiemtra2();
num=0;
break;
}
case 7:
{
kiemtra3();
num=0;
break;
}
case 8:
{
kiemtra4();
num=0;
break;
}

}}}
File Kèm Theo
File Type: zip dtmf.zip (728 Bytes, 144 lần tải)
saubeo6600 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 

Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 05:01 AM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam