#include <AT89X51.H>
#include "Link.h"
#include "delay.h"
/********************变量定义*********************/
sbit Data = P2^0;
sbit Clk = P2^1;
uint8 code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void Write_Byte(uint8 temp)
{
uint8 i;
for(i=0;i<8;i++)
{
Clk=0;
if((temp&0x80)!=0x80)
Data=0;
else
Data=1;
Clk=1;
temp<<=1;
}
}
void main(void)
{
while(1)
{
uint8 i;
for(i=0;i<10;i++)
{
Write_Byte(table[i]);
delay1ms(1000);
}
}
}
串口方式0进行扩展
注意串口通信时,低位在前,高位在后发送。
#include <AT89X51.H>
#include "Link.h"
#include "delay.h"
/********************变量定义*********************/
//#define tim 65536-10000
uint8 code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//uint8 Led;
/****************************************************************
*函数功能:初始化定时器
*入口参数:无
*出口参数:无
****************************************************************/
void TIMER_Init(void)
{
SCON = 0x00; //串行移位方式
EA = 1;
ES = 1;
}
void main(void)
{
TIMER_Init();
while(1)
{
uint8 i;
SBUF=table[i++%10];
while(!TI);
TI=0;
delay1ms(1000);
}
}
评论