萌新刚学51单片机 学完了点阵,就想着搞个爱心来看看,可是萌新无论怎么试,我这程勋烧录出来的爱心都是180°倒过来的,大佬们有知道问题的嘛
程序如下↓↓↓
#include<reg52.h>
#include<intrins.h>
typedef unsigned char u8;
typedef unsigned int u16;
sbit SER=P3^4;
sbit rclk=P3^5;
sbit SRCLK=P3^6;
void delay(u16 i)
{
while(i--);
}
u8 ledduan[]={0x1C,0x22,0x42,0x84,0x84,0x42,0x22,0x1C};
u8 ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void hc595send(u8 dat)
{
u8 a;
SRCLK=0;
rclk=0;
for(a=0;a<8;a++)
{
SER=dat>>7;
dat<<=1;
SRCLK=1;
_nop_();
_nop_();
SRCLK=0;
}
rclk=1;
_nop_();
_nop_();
rclk=0;
}
void main()
{
u8 i;
while(1)
{
P0=0x7f;
for(i=0;i<8;i++)
{
P0=ledwei;
hc595send(ledduan);
delay(100);
hc595send(0x00);
}
}
}
|