Hic, bác davekieu này đúng là cao thủ võ lâm, sai chính tả nhiều quá, 100 lỗi là phải rồi!!!!!!!!!!!!!!.
Sửa lỗi cho bác đuối luôn, chạy hay không là do bác lập trình thôi!!!!!!!!!.
#include <16F877.h>
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, NOPUT
#use delay(clock=12000000)
#use Fast_IO(B)
#use Fast_IO(D)
int dulieuthu=0x00;
int bitdo;
Void xulydulieu();
void xuat(n);
void main()
{
set_tris_d(0); // tat ca chan d deu la ngo ra gan led
set_tris_b(1); // b1 la ngo vao con lai la ngo ra
enable_interrupts(INT_EXT); //cho phep ngat ngoai
ext_int_edge(H_to_L);
enable_interrupts(GLOBAL); // ok ngat
while(1)
{
xulydulieu();
xuat(dulieuthu);
delay_ms(200);
}
}
void xuat(n)
{
if(n==0x00) {output_d(0b11000000);}
else if(n==0x01) {output_d(0b10100100);} //kenh 1
else if(n==0x02) {output_d(0b10110000);} //kenh 2
else if(n==0x03) {output_d(0b10011001);} //kenh 3
else if(n==0x04) {output_d(0b10010010);} //kenh 4
else if(n==0x05) {output_d(0b10000010);} //kenh 5
else if(n==0x06) {output_d(0b11011000);} //kenh 6
else if(n==0x07) {output_d(0b10000000);} //kenh 7
else if(n==0x08) {output_d(0b10010000);} //kenh 8
else if(n==0x09) {output_d(0b11000000);} //kenh 9
else {}; // do nothing
}
#INT_EXT
void xulydulieu()
{
int i;
i=1;
while(input(pin_b0))
{
delay_us(200);
i++;
}
if((i<14)&&(i>8)) //i*2~24. ~2400us
{
for(i=0;i<8;i++)
{
while(input(PIN_B0))
{delay_us(800);}
bitdo=input(PIN_B0);
if (bitdo)// bitdo = 1
{bit_set(dulieuthu,i);}
}
}
}
|