永发信息网

单片机AT89C51、P2口位码控制、用定时器的方法、IF语句输入、实现0~9的加一计数显示、求延时0.5秒的程序

答案:2  悬赏:50  手机版
解决时间 2021-05-18 21:55
单片机AT89C51、P2口位码控制、用定时器的方法、IF语句输入、实现0~9的加一计数显示、求延时0.5秒的程序
最佳答案

#include < reg51.h >
#include < intrins.h >


unsigned char code Bmp510[]=
{
0x00,0x7E,0x81,0x81,0x81,0x7E,0x00,0x00,0x82,0xFF,0x80,0x00,0x00,0xC6,0xA1,0x91,
0x89,0x86,0x00,0x42,0x81,0x89,0x89,0x76,0x00,0x10,0x2C,0x22,0xFF,0xA0,0x00,0x4F,
0x89,0x89,0x89,0x71,0x00,0x7E,0x89,0x89,0x8B,0x70,0x00,0x03,0x01,0xF9,0x07,0x01,
0x00,0x76,0x89,0x89,0x89,0x76,0x00,0x0E,0xD1,0x91,0x91,0x7E,0x00,0x80,0xF8,0x27,
0x3C,0xE0,0x80,0x81,0xFF,0x89,0x89,0x76,0x00,0x7E,0x81,0x81,0x81,0x43,0x00,0x81,
0xFF,0x81,0x81,0x7E,0x00,0x81,0xFF,0x89,0x9D,0xC3,0x00,0x81,0xFF,0x89,0x1D,0x03,
0x00,0x3C,0x42,0x81,0x91,0x73,0x10,0x81,0xFF,0x08,0x08,0xFF,0x81,0x81,0x81,0xFF,
0x81,0x81,0x00,0x80,0x01,0x01,0xFF,0x01,0x01,0x81,0xFF,0x89,0x34,0xC3,0x81,0x81,
0xFF,0x81,0x80,0x80,0xC0,0xFF,0x0F,0xF0,0x0F,0xFF,0x00,0x81,0xFF,0x8C,0x31,0xFF,
0x01,0x7E,0x81,0x81,0x81,0x7E,0x00,0x81,0xFF,0x89,0x09,0x06,0x00,0x7E,0xA1,0xA1,
0xC1,0x7E,0x00,0x81,0xFF,0x89,0x19,0xE6,0x80,0xC6,0x89,0x89,0x91,0x63,0x00,0x03,
0x81,0xFF,0x81,0x03,0x00,0x01,0x7F,0x80,0x80,0x7F,0x01,0x01,0x1F,0xE0,0x38,0x07,
0x01,0x07,0xF8,0x0F,0xF8,0x07,0x00,0x81,0xE7,0x18,0xE7,0x81,0x00,0x01,0x87,0xF8,
0x87,0x01,0x00,0x83,0xE1,0x99,0x87,0xC1,
};
unsigned char code col_s[8]={1,2,4,8,16,32,64,128,};
unsigned char count = 0;
unsigned char col = 0;
unsigned char timer1s_flag = 0;
void delayms(unsigned char ms);
void delay(unsigned char t);


unsigned int ttt;

void main()
{
TMOD=0x01 ;
TH0=0xed ;
TL0=0xff ;
EA=1;
ET0=1;
TR0=1 ;

while(1)
{
if(timer1s_flag>=50){
timer1s_flag = 0;
count++;
count %= 10;
}
}
}



// 定时器0中断服务程序.

void timer0() interrupt 1 using 2
{
TH0=0xed ;
TL0=0xff ;
ttt++;
//if(ttt>=1000)
{
ttt = 0;
timer1s_flag++;
P1 = 0;
//P0 = ~col_s[col];
P0 = col;
P1 = Bmp510[count*6+col];
col++;
col %= 6;
}

}


这个程序时实现8*8点阵led显示的 0~9 循环显示。间隔500ms


全部回答

#include "REG51.H"

unsigned char tag = 0; unsigned char count = 0;

void INT_0(void) interrupt 1 { count ++; if( count >= 10 ) { count = 0; tag ++; if( tag >= 10 ) { tag = 0; } } }

void Delay() { int i; for( i = 0; i < 0xff; i ++ ) { } }

main() { unsigned char Table[] = { 0x40, 0x4f, 0x24, 0x30,0x19, 0x12, 0x02, 0x78, 0x00, 0x10 }; TMOD = 0x01; TH0 = 0x3c; TL0 = 0xb0; EA = 1; ET0 = 1; TR0 = 1; while(1) { P2 = Table[tag]; Delay(); } }

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
什么样的感情不会过期?
我累了,她对我,凭心说,不好,我怎么办,想放又
什么是高清电视?
中山三乡汽车站到古玩城坐哪路车
N78自制主题软件怎样安装?
海林市牡丹江审美美发这个地址在什么地方,我
怎么做英语句型转换的 5分
有一个字,人人见都会念错?是什么字
卧室水管如何隐匿
回乡偶书 诗中3,4两句,触发了作者怎样的感情?
各位哥哥姐姐告我一下怎样追女孩子
怎样才可以完全忘记曾经?
柘城县商丘柘城县龙成装饰装修工程店这个地址
DNF第九章的内容、会开55级紫武器吗?
怎么进入有密码的空间 不是好友
推荐资讯
医院十年院庆祝福语,急需院庆六十周年祝福语
什么雪地靴颜色县腿细,好配衣服啊
雨湖区湘潭海尔空调(韶山中路)地址在什么地方
汉南区武汉汉南区东荆街卫生院地址在什么地方
梦幻西游90级光辉鞋子卖多少钱
天津花店周六日兼职
朵唯手机是否可以下载2010版QQ?
为什么好心不得好报
杭州一线大学有哪几所?
懂生意的来
有谁代刷DNF?钱给级给
怎样可以迅速的变成熟?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?