PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > PIC - Thiết kế và Ứng dụng

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

PIC - Thiết kế và Ứng dụng Ý tưởng cho các sản phẩm sử dụng PIC/dsPIC và các sản phẩm của Microchip

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 31-03-2011, 11:24 PM   #15
lambaotrung
Đệ tử 5 túi
 
Tham gia ngày: Jan 2010
Bài gửi: 96
:
bạn ơi mình có vấn đề cần hỏi thêm

như vậy mình có giá trị cửa "tinh"

như vậy khi mình đếm đếm 1000 chẩn hạng

minh muốn nó ngưng lại thi phải làm sao...

core mình muốn việt co nội dùng là
có a = 1000
int32 tinh,a;

ấn 1 phím

dem++;
hien thi tinh lên LCD

if (dem>a)
{
core
}
else;

nhưng khi mình làm nhu thế này

#include <16f877a.h>
#fuses xt,nowdt,noprotect,nolvp
#use delay(clock=4000000)

#use fast_io(b)
#use fast_io(d)

#byte portb=0x6
#byte portd=0x8
#byte porta=0x5
#byte portc=0x07
#bit RA0 = porta.0

#bit rs = portb.0
#bit rw = portb.1
#bit e = portb.2


void lenh();
void xuat();
void khoitao();

void lenh()
{rs=0;
rw=0;
e=1;
e=0;
delay_ms(5);
}

void xuat()
{
e=1;
rs=1;
rw=0;
e=0;
delay_ms(5);
}
void khoitao()
{portd=0x01;
lenh();
portd=0x0e;
lenh();
portd=0x80;
lenh();
portd=0x38;
lenh();
delay_ms(5);
}


void main()
{
int32 i, dem,donvi,chuc,tram,nghin,chucnghin,a;
const char tenem[] = " lam bao trung ";
char const ht[]={'0','1','2','3','4','5','6','7','8','9',' '};

set_tris_b(0);
set_tris_d(0);
set_tris_c(0x0);
khoitao();
a=1000;
////////////////////////////////////////////////////////////////////////////////
while(1)
{
if(dem>a)
{
output_c(0xff);
}
else
output_c(0xf0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
while(2)
{
if (ra0==0)
{
do{}
while (ra0==0);
dem=dem+100;
}

}

chucnghin=dem/10000;
nghin=(dem%10000)/1000;
tram=(dem%1000)/100;
chuc=(dem%100)/10;
donvi=dem%10;
portd=0x0c;
lenh();

for(i=0;i<20;i++)
{
portd=0x82;
lenh();
portd=ht[chucnghin];
xuat();
portd=ht[nghin];
xuat();
portd=ht[tram];
xuat();
portd=ht[chuc];
xuat();
portd=ht[donvi];
xuat();
delay_ms(5);

portd=0xc0;
lenh();

for(i=0;i<30;i++)
{
portd=tenem[i];
xuat();
}

}
}
}


các bạn chú ý chổ

////////////////////

while(1)
{
if(dem>a)
{
output_c(0xff);
}
else
output_c(0xf0);

///////////////////////////////////
minh làm như thế thi nó ko hiển thi nửa......
lambaotrung 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à 04:11 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