em đang làm cái led matrix dùng 74hc595 nhưng khi biên dịch ra thì bị lỗi.mong cao thủ giúp em với.đây là code của em
#include <16f877a.h>
#include <def_877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4M)
int8 const chay[]={0x08,0x04,0x02,0x01,0x80,0x40,0x20,0x10};
int8 const data[]={0XFF,0X00,0XFF,0X00,0XFD,0XFB,0XF7,0XEF};
void 595(int8 temp)
{
#bit fla=temp.7;
int8 i;
for(i=0;i<=7;i++)
{
if(fla)
{
output_high(pin_b0);data
}
else
output_low(pin_b0); data
output_high(pin_b1);clock
output_low(pin_b1);clock
temp=temp<<1;
}
output_high(pin_b2);chot
output_low(pin_b2);
}
void main()
{
int8 m;
trisb=0x00;
trisd=0x00;
while(true)
{
for(m=0;m<=7;m++)
{
temp=chay[m];
595();
portd=data[m];
}
}
}
#include <16f877a.h>
#include <def_877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4M)
int8 const chay[]={0x08,0x04,0x02,0x01,0x80,0x40,0x20,0x10};
int8 const data[]={0XFF,0X00,0XFF,0X00,0XFD,0XFB,0XF7,0XEF};
void 595(int8 temp)
{
#bit fla=temp.7;
int8 i;
for(i=0;i<=7;i++)
{
if(fla)
{
output_high(pin_b0);data
}
else
output_low(pin_b0); data
output_high(pin_b1);clock
output_low(pin_b1);clock
temp=temp<<1;
}
output_high(pin_b2);chot
output_low(pin_b2);
}
void main()
{
int8 m;
trisb=0x00;
trisd=0x00;
while(true)
{
for(m=0;m<=7;m++)
{
temp=chay[m];
595();
portd=data[m];
}
}
}
Comment