修改一个51单片机C语言程序问题,要求实现数码管灯动态闪烁。
程序如下#include<reg52.h>#include<intrins.h>#defineuintunsignedint#defineucharunsignedcha...
程序如下
#include<reg52.h>#include<intrins.h>#define uint unsigned int#define uchar unsigned charuchar i,wei,ge,shi;uint temp;sbit dula=P2^6;sbit wela=P2^7;uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83, 0xc6, 0xa1,0x86, 0x8e};void main(){ TH0=(65536-5000)/256; TL0=(65536-5000)%256; i=0; TMOD=0x01; ET0=0x01; EA=1; TR0=1; temp=23; ge=temp%10; shi=temp/10;
while(1) { wela=1; P0=~0xfe; wela=0; dula=1; P0=table[shi]; dula=0; if(i==1) { wela=1; P0=~0xfd; wela=0; i=0; dula=1; P0=table[ge]; dula=0; }
}
}
void Timer0IRQ(void) interrupt 1{ TH0=(65536-5000)/256; TL0=(65536-5000)%256; i++;
}修改程序,使它在数码管上动态显示23,不能另起炉灶编程,要基于本程序为基础。 展开
#include<reg52.h>#include<intrins.h>#define uint unsigned int#define uchar unsigned charuchar i,wei,ge,shi;uint temp;sbit dula=P2^6;sbit wela=P2^7;uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83, 0xc6, 0xa1,0x86, 0x8e};void main(){ TH0=(65536-5000)/256; TL0=(65536-5000)%256; i=0; TMOD=0x01; ET0=0x01; EA=1; TR0=1; temp=23; ge=temp%10; shi=temp/10;
while(1) { wela=1; P0=~0xfe; wela=0; dula=1; P0=table[shi]; dula=0; if(i==1) { wela=1; P0=~0xfd; wela=0; i=0; dula=1; P0=table[ge]; dula=0; }
}
}
void Timer0IRQ(void) interrupt 1{ TH0=(65536-5000)/256; TL0=(65536-5000)%256; i++;
}修改程序,使它在数码管上动态显示23,不能另起炉灶编程,要基于本程序为基础。 展开
3个回答
推荐于2017-08-19
展开全部
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned charsbit dula=P2^6;
sbit wela=P2^7;
uchar i,wei,ge,shi;
uint temp=23;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90 ,0x88,0x83, 0xc6, 0xa1,0x86, 0x8e};//void Timer0IRQ(void) interrupt 1
//{
// TH0=(65536-5000)/256;
// TL0=(65536-5000)%256;
// i++;
//}
delay(uint i)
{
uint h,f;
for(h=0;h<i;h++)
for(f=0;f<125;f++);
} void xs_hs()
{
ge=temp/10;
shi=temp%10;
wela=1;
P0=table[shi];
delay(5);
wela=0;
dula=1;
P0=table[ge];
delay(5);
dula=0;
}
void main()
{
// TMOD=0x01;
// TH0=(65536-5000)/256;
// TL0=(65536-5000)%256;
// i=0;
// EA=1;
// ET0=1;
// TR0=1; while(1)
{
xs_hs();
} }
#define uint unsigned int
#define uchar unsigned charsbit dula=P2^6;
sbit wela=P2^7;
uchar i,wei,ge,shi;
uint temp=23;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90 ,0x88,0x83, 0xc6, 0xa1,0x86, 0x8e};//void Timer0IRQ(void) interrupt 1
//{
// TH0=(65536-5000)/256;
// TL0=(65536-5000)%256;
// i++;
//}
delay(uint i)
{
uint h,f;
for(h=0;h<i;h++)
for(f=0;f<125;f++);
} void xs_hs()
{
ge=temp/10;
shi=temp%10;
wela=1;
P0=table[shi];
delay(5);
wela=0;
dula=1;
P0=table[ge];
delay(5);
dula=0;
}
void main()
{
// TMOD=0x01;
// TH0=(65536-5000)/256;
// TL0=(65536-5000)%256;
// i=0;
// EA=1;
// ET0=1;
// TR0=1; while(1)
{
xs_hs();
} }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询