giup em ve chuong trinh ccs
2 posters
Trang 1 trong tổng số 1 trang
giup em ve chuong trinh ccs
thua thay hom nay em viet chuong trinh dem sp hien thi led 7 doan.ko hieu sao bt thi led ko sang het 4 con.khi co sp di qua thi led moi sang du 4 con dong thoi so san pham tang len 1.day la code cua em.
#include <16f877a.h>
#fuses nowdt,noprotect,nolvp,xt,put
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit a4=porta.4
unsigned char spch=0,spdv=0,tch=0,tdv=0,i=0,j=0,w=0;
const unsigned char led7[]={0b11000000, 0b11111001, 0b10100100, 0b10110000, 0b10011001,\
0b10010010, 0b10000010, 0b11111000, 0b10000000, 0b10010000};
void tach_so();
void quet_led();
void kt();
void main()
{ set_tris_a(0b11111);
set_tris_b(0);
set_tris_c(0b0000);
while(1)
{kt();
tach_so();
quet_led();
}}
void kt()
{
if (a4==0)
{while(a4==0)
{}
i++;
if(i==12)
{i=0;
j++;
}
tach_so();
quet_led();
}}
void tach_so()
{
spch=i/10;
spdv=i%10;
tch=j/10;
tdv=j%10;
}
void quet_led()
{
for (w=1;w<=50;++w)
{
portc=(0b1110);
portb=led7[spch];
delay_ms(5);
portc=(0b1101);
portb=led7[spdv];
delay_ms(5);
portc=(0b1011);
portb=led7[tch];
delay_ms(5);
portc=(0b0111);
portb=led7[tdv];
delay_ms(5);
}
}
#include <16f877a.h>
#fuses nowdt,noprotect,nolvp,xt,put
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit a4=porta.4
unsigned char spch=0,spdv=0,tch=0,tdv=0,i=0,j=0,w=0;
const unsigned char led7[]={0b11000000, 0b11111001, 0b10100100, 0b10110000, 0b10011001,\
0b10010010, 0b10000010, 0b11111000, 0b10000000, 0b10010000};
void tach_so();
void quet_led();
void kt();
void main()
{ set_tris_a(0b11111);
set_tris_b(0);
set_tris_c(0b0000);
while(1)
{kt();
tach_so();
quet_led();
}}
void kt()
{
if (a4==0)
{while(a4==0)
{}
i++;
if(i==12)
{i=0;
j++;
}
tach_so();
quet_led();
}}
void tach_so()
{
spch=i/10;
spdv=i%10;
tch=j/10;
tdv=j%10;
}
void quet_led()
{
for (w=1;w<=50;++w)
{
portc=(0b1110);
portb=led7[spch];
delay_ms(5);
portc=(0b1101);
portb=led7[spdv];
delay_ms(5);
portc=(0b1011);
portb=led7[tch];
delay_ms(5);
portc=(0b0111);
portb=led7[tdv];
delay_ms(5);
}
}
Re: giup em ve chuong trinh ccs
Em them vao chuong trinhgaonljne0809 đã viết:thua thay hom nay em viet chuong trinh dem sp hien thi led 7 doan.ko hieu sao bt thi led ko sang het 4 con.khi co sp di qua thi led moi sang du 4 con dong thoi so san pham tang len 1.day la code cua em.
#include <16f877a.h>
#fuses nowdt,noprotect,nolvp,xt,put
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#use fast_io(d)
#byte porta=0x05
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit a4=porta.4
unsigned char spch=0,spdv=0,tch=0,tdv=0,i=0,j=0,w=0;
const unsigned char led7[]={0b11000000, 0b11111001, 0b10100100, 0b10110000, 0b10011001,\
0b10010010, 0b10000010, 0b11111000, 0b10000000, 0b10010000};
void tach_so();
void quet_led();
void kt();
void main()
{ set_tris_a(0b11111);
set_tris_b(0);
set_tris_c(0b0000);
while(1)
{kt();
tach_so();
quet_led();
}}
void kt()
{
if (a4==0)
{while(a4==0)
{}
i++;
if(i==12)
{i=0;
j++;
}
tach_so();
quet_led();
}}
void tach_so()
{
spch=i/10;
spdv=i%10;
tch=j/10;
tdv=j%10;
}
void quet_led()
{
for (w=1;w<=50;++w)
{
portc=(0b1110);
portb=led7[spch];
delay_ms(5);
portc=(0b1101);
portb=led7[spdv];
delay_ms(5);
portc=(0b1011);
portb=led7[tch];
delay_ms(5);
portc=(0b0111);
portb=led7[tdv];
delay_ms(5);
}
}
portc=(0b1011);
portb=led7[tch];
delay_ms(5);
portb=(ob11111111);
tuong tu cho cac doan con lai
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|