标题:
想要数码管从0到f切换,但是没成功
[打印本页]
作者:
51xueze
时间:
2018-4-14 20:59
标题:
想要数码管从0到f切换,但是没成功
AT89C52.pdf
(596.3 KB, 下载次数: 6)
2018-4-14 20:57 上传
点击文件名下载附件
芯片手册
原理图QX-mini51.pdf
(154.08 KB, 下载次数: 5)
2018-4-14 20:57 上传
点击文件名下载附件
程序①:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
uchar num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z);
void main()
{
while(1)
{
for(num=0;num<16;num++)
{
P0=table[num];
P2_0=0;
P2_0=1;
P0=table[num];
P2_1=0;
P2_1=1;
P0=table[num];
P2_2=0;
P2_2=1;
P0=table[num];
P2_3=0;
P2_3=1;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
程序②:
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
uchar num;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,
0xf8,0x80,0x90};
void delay(uint z);
void main()
{
while(1)
{
for(num=0;num<16;num++)
{
P0=table[num];
P2_0 = 0;
P2_0 = 1;
P0=table[num];
P2_1 = 0;
P2_1 = 1;
P0=table[num];
P2_2 = 0;
P2_2 = 1;
P0=table[num];
P2_3 = 0;
P2_3 = 1;
delay(1000);
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
作者:
wulin
时间:
2018-4-15 07:04
4个数码管显示相同数字
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={ //共阳数码管段码"0~f"
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
uchar num;
P2 &= 0xf0;
while(1)
{
for(num=0;num<16;num++)
{
P0=table[num];
delay(1000);
}
}
}
作者:
51xueze
时间:
2018-4-15 22:21
wulin 发表于 2018-4-15 07:04
4个数码管显示相同数字
#include
#define uchar unsigned char
谢谢你!
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1