51单片机中使用8*8点阵做了个笑脸,为什么一直在闪烁?有没有什么办法能让它稳定下来?
#include "regx52.h"
#include "Delay.h"
#include "T0.h"
sbit SER = P3 ^ 4;
sbit RCK = P3 ^ 5;
sbit SCK = P3 ^ 6;
unsigned char arr[]={
0x7E,0x91,0xA3,0xA5,
0xA3,0x91,0x7E,0x00,
0x00,0x7E,0xA1,0x93,
0x95,0x93,0xA1,0x7E,};
void _74hc595_init()
{
SER = 0; RCK = 0; SCK = 0;
}
void _74hc595_data(unsigned char Data)
{
unsigned char i;
for (i = 0; i < 8; i++)
{
SER = Data & (0x80 >> i);
SCK = 1; SCK = 0;
}
RCK = 1; RCK = 0;
}
void _74hc595(unsigned char n, unsigned char Data)
{
_74hc595_data(Data);
P0 = ~(0x80 >> n);Delay(1);
P0 = 0xff;
}
void main()
{
unsigned char k;
_74hc595_init();
while (1)
{
_74hc595(0,arr[0]);
_74hc595(1,arr[1]);
_74hc595(2,arr[2]);
_74hc595(3,arr[3]);
_74hc595(4,arr[4]);
_74hc595(5,arr[5]);
_74hc595(6,arr[6]);
_74hc595(7,arr[7]);