PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > Cơ bản về vi điều khiển và PIC

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

Cơ bản về vi điều khiển và PIC Những bài hướng dẫn cơ bản nhất để làm quen với vi điều khiển PIC

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 19-01-2014, 10:40 PM   #1
luonghuy99
Nhập môn đệ tử
 
Tham gia ngày: Sep 2010
Bài gửi: 2
:
tro giup minh voi ve dong co buoc +lcd

day la chuong trinh cua e.sao e lap trinh dung theo thay chi.luc e mo phong thi dong co k chay.can may a giup do cho e.thanks
email cua e: tranquocviet4788@yahoo.com

#include <18f4620.h>
#use delay(clock = 20000000)
#byte porte=0xf84
#byte portd=0xf83
#byte portc=0xf82
#byte portb=0xf81
#byte porta=0xf80

#byte trise=0xf96
#byte trisd=0xf95
#byte trisc=0xf94
#byte trisb=0xf93
#byte trisa=0xf92
#bit sw1=portb.0
#bit sw2=portb.1
#bit sw3=portb.2
//#bit asd=portd.0
//#bit asd=portc.0
int x,y,i,giatri=10,dem=10,tam,MOD; // int=int8 giatri toi da 255

int so[8]={1,2,4,8,16,32,64,128};
int so1[8]={1,2,4,8,16,32,64,128};
int co1;
void nut_tang()
{
if(sw1==0)
{ delay_ms(1);
dem++;
if(dem++)
{
y=i+10;
}
if(dem==1000)
{
dem=10;
}
while(sw1==0);
}
}
// ham giam :
// moi lan an thi giam bien dem mot don vi, vong tron (neu =0 thi tro ve so mat dinh 10)

void nut_giam()
{
if(sw2==0)
{ delay_ms(1);
dem--;
if(dem--)
{
y=i-10;
}
if(dem==0)
{
dem=1000;
}
// co1 =!co1;


while(sw2==0);
}
}
void dieu_khien()
{
for(i=0;i<y;i++)
{
output_d(0b00000001);
delay_ms(1);
output_d(0b00000010);
delay_ms(1);
output_d(0b00000100);
delay_ms(1);
output_d(0b00001000);
delay_ms(1);
}
output_d(0);
}
void BMOD()
{if(sw3==0)
{
delay_ms(10);
MOD++;
while(sw3==0);
}

switch (MOD)
{
case 1:nut_tang();dieu_khien();break;
case 2:nut_giam();dieu_khien();break;
}
}

void main()
{trisd=0;
trisc=0;
trisb=255;

//co1 = 0;
while(1)
{
// thuc thi
// goi y: an va giu
// hoac an mot nut start

BMOD();
//co1 = !co1;

// while(1); // dung luon chuong trinh

}
}
luonghuy99 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


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à 01:51 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