STC89C52单片机C语言程序求解 5
#include<reg52.h>//调用单片机头文件#defineucharunsignedchar//无符号字符型宏定义变量范围0~255#defineuintuns...
#include <reg52.h> //调用单片机头文件
#define uchar unsigned char //无符号字符型 宏定义 变量范围0~255
#define uint unsigned int //无符号整型 宏定义 变量范围0~65535
// // 1 2 3 4 5 6 7 8
uint code we[16]={0xfffb,0xffdf,0xff7f,0xffef,0xfffe,0xfffd,0xffbf,0xfff7,
0xdfff,0xfbff,0xfdff,0x7fff,0xf7ff,0xbfff,0xfeff,0xefff}; //左
/***********************1ms延时函数*****************************/
void delay_1ms(uint q)
{
uint i,j;
for(i=0;i<q;i++)
for(j=0;j<50;j++);
}
uchar geshu = 16;
uchar hanzi[32] ;
uchar i;
sbit SI=P3^6;
sbit SCK=P3^3; //上升沿有效
sbit RCK=P3^4; //上升沿有效
/**********发送一个数据************/
void send_byte(uchar a)
{
uchar i,nn;
nn=a;
for(i=0;i<8;i++)
{
SCK=0;
nn<<=1;
SI=CY;
SCK=1;
}
}
/**********595输出************/
void out()
{
RCK=0;
RCK=1;
}
uint flag_value = 0;
uchar you = 0 ;
/**********主函数************/
void main()
{
static uchar value,value1,j;
for(i=0;i<32;i++ )
hanzi[i] = 0xff;
flag_value = 0;
while(1)
{
value ++;
if(value >= 10) //延时进来处理
{
value = 0;
value1 ++;
if(value1 <= 16)
{
value1 = 0;
for(j=0;j<15;j++)
{
hanzi[j*2+1] = hanzi[j*2+3] ;
hanzi[j*2] = hanzi[j * 2+2];
}
hanzi[30] = table[you][flag_value * 2];
hanzi[31] = table[you][flag_value * 2 + 1];
flag_value ++;
if(flag_value >= 16)
{
flag_value = 0;
you ++;
if(you >= geshu) //字全部显示完了
you = 0;
}
}
}
for(i=0;i<16;i++)
{
out(); //595输出
P2 = we[i] / 256;
P0 = we[i] % 256;
send_byte(hanzi[i*2]) ; //上
send_byte(hanzi[i*2+1]) ; //下
delay_1ms(1);
}
}
} 展开
#define uchar unsigned char //无符号字符型 宏定义 变量范围0~255
#define uint unsigned int //无符号整型 宏定义 变量范围0~65535
// // 1 2 3 4 5 6 7 8
uint code we[16]={0xfffb,0xffdf,0xff7f,0xffef,0xfffe,0xfffd,0xffbf,0xfff7,
0xdfff,0xfbff,0xfdff,0x7fff,0xf7ff,0xbfff,0xfeff,0xefff}; //左
/***********************1ms延时函数*****************************/
void delay_1ms(uint q)
{
uint i,j;
for(i=0;i<q;i++)
for(j=0;j<50;j++);
}
uchar geshu = 16;
uchar hanzi[32] ;
uchar i;
sbit SI=P3^6;
sbit SCK=P3^3; //上升沿有效
sbit RCK=P3^4; //上升沿有效
/**********发送一个数据************/
void send_byte(uchar a)
{
uchar i,nn;
nn=a;
for(i=0;i<8;i++)
{
SCK=0;
nn<<=1;
SI=CY;
SCK=1;
}
}
/**********595输出************/
void out()
{
RCK=0;
RCK=1;
}
uint flag_value = 0;
uchar you = 0 ;
/**********主函数************/
void main()
{
static uchar value,value1,j;
for(i=0;i<32;i++ )
hanzi[i] = 0xff;
flag_value = 0;
while(1)
{
value ++;
if(value >= 10) //延时进来处理
{
value = 0;
value1 ++;
if(value1 <= 16)
{
value1 = 0;
for(j=0;j<15;j++)
{
hanzi[j*2+1] = hanzi[j*2+3] ;
hanzi[j*2] = hanzi[j * 2+2];
}
hanzi[30] = table[you][flag_value * 2];
hanzi[31] = table[you][flag_value * 2 + 1];
flag_value ++;
if(flag_value >= 16)
{
flag_value = 0;
you ++;
if(you >= geshu) //字全部显示完了
you = 0;
}
}
}
for(i=0;i<16;i++)
{
out(); //595输出
P2 = we[i] / 256;
P0 = we[i] % 256;
send_byte(hanzi[i*2]) ; //上
send_byte(hanzi[i*2+1]) ; //下
delay_1ms(1);
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询