锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

试验数码管上显示数字( 单片机直接实现位选 共阴极)

时间:2024-05-09 09:37:10


/**********************************************************************************
* 标题: 试验上显示数字( 单片机直接实现位选 共阴极) *
* *
* 连接方法:P0与J12 用8PIN排线连接 P1与JP16 用排线连接 *
***********************************************************************************
* *
* 用573控制和单片机脚直接位选控制(非译码器控制)数码管 *
***********************************************************************************/
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=0;y<113;y++)
{
}
}
}
unsigned int code dbit[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdF,0xbF,0x7F};
unsigned int code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
void main()
{
while(1)
{
P1=dbit[4];
P0=num[9];
}
}


位定义

#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
uchar code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=0;y<113;y++)
{
}
}
}
void main()
{
while(1)
{
LSA=0;
LSB=0;
LSC=0;
P0=num[6];
delay(2);
LSA=1;
LSB=0;
LSC=0;
P0=num[6];
delay(2);
}
}


//让八个数码管全部亮并且从0~9循环

#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar num;
uchar wnum=0x00;
uchar code dbit[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//段选,选择要显示的数字
//uchar code wnum[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdF,0xbF,0x7F};//八位数码管
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=0;y<113;y++)
{
}
}
}
void main()
{
P1=wnum;
while(1)
{
for(num=0;num<10;num++)
{
P0=dbit[num];
delay(500);
}
}
}


-电子元器件采购网(www.ruidan.com)是本土元器件目录分销商,采用“小批量、现货、样品”销售模式,致力于满足客户多型号、高质量、快速交付的采购需求。 自建高效智能仓储,拥有自营库存超过50,000种,提供一站式正品现货采购、个性化解决方案、选型替代等多元化服务。
锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章