如何在一段C语言程序中添加一段计时中断程序 使程序在运行10秒后跳转至下一段程序!
程序如下:#include<reg51.h>unsignedinttimecount;unsignedcharcodetab[]={0xfe,0xfd,0xfb,0xf7...
程序如下:
#include<reg51.h>
unsigned int timecount;
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code shuzu[]={
0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00, //0
0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00, //1
0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //2
0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00, //3
0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00, //4
0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00, //5
0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00, //6
0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00, //7
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00, //8
0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00, //9
0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00, //P
0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00, //R
0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00, //E
0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00, //C
0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00, //H
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00, //I
0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00, //N
0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00 //中
};
void delay(unsigned int t)
{
while (t--)
{;}
}
void main(void)
{ unsigned char i,j,a;
while(1)
{
for(i=0;i<=136;i++) //循环扫描一遍136帧
for(a=0;a<=80;a++) //移动速度
{
for(j=0;j<=7;j++)
{
P0=shuzu[i+j];
P2=tab[j];
delay(10);
}
}
}
}
基于51单片机的~ 展开
#include<reg51.h>
unsigned int timecount;
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code shuzu[]={
0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00, //0
0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00, //1
0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //2
0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00, //3
0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00, //4
0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00, //5
0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00, //6
0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00, //7
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00, //8
0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00, //9
0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00, //P
0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00, //R
0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00, //E
0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00, //C
0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00, //H
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00, //I
0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00, //N
0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00 //中
};
void delay(unsigned int t)
{
while (t--)
{;}
}
void main(void)
{ unsigned char i,j,a;
while(1)
{
for(i=0;i<=136;i++) //循环扫描一遍136帧
for(a=0;a<=80;a++) //移动速度
{
for(j=0;j<=7;j++)
{
P0=shuzu[i+j];
P2=tab[j];
delay(10);
}
}
}
}
基于51单片机的~ 展开
3个回答
展开全部
采用多线程,每隔10秒给主程序一个命令 可以实现跳转
追问
51单片机不支持多线程 嗨
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不能直接延时10秒么
追问
延时也可以~能麻烦您给编写一段吗?我是初学者实在不会啊
追答
你那个delay的函数就是延时啊,你要调用的时候就delay(100);就行啊,里面的那个数字你自己调一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询