数码管部分电路与proteus仿真电路以及相关代码如下。
CT107平台数码管模块
proteus仿真电路
#include "smg.h"
unsigned char smg_du_tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};
unsigned char smg_we_tab1[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char smg_we_tab2[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char yi,er,san,si,wu,liu,qi,ba;
void smg_liushui()
{
unsigned char i;
for(i=0;i<8;i++)
{
P2=0xc0;
P0=smg_we_tab1;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=0x00;
P2=0x1f;
P0=0x00;
delay_ms(500);
}
}
void smg_off()
{
unsigned char i;
for(i=0;i<8;i++)
{
P2=0xc0;
P0=smg_we_tab2;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=0x00;
P2=0x1f;
P0=0x00;
delay_ms(500);
}
}
void display1(unsigned char yi, unsigned char er)
{
P2=0xc0;
P0=0x01;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[yi];
P2=0x1f;
P0=0x00;
delay_ms(1);
P2=0xc0;
P0=0x02;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[er];
P2=0x1f;
P0=0x00;
delay_ms(1);
}
void display2(unsigned char san,unsigned char si)
{
P2=0xc0;
P0=0x04;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[san];
P2=0x1f;
P0=0x00;
delay_ms(1);
P2=0xc0;
P0=0x08;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[si];
P2=0x1f;
P0=0x00;
delay_ms(1);
}
void display3(unsigned char wu, unsigned char liu)
{
P2=0xc0;
P0=0x10;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[wu];
P2=0x1f;
P0=0x00;
delay_ms(1);
P2=0xc0;
P0=0x20;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[liu];
P2=0x1f;
P0=0x00;
delay_ms(1);
}
void display4(unsigned char qi, unsigned char ba)
{
P2=0xc0;
P0=0x40;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[qi];
P2=0x1f;
P0=0x00;
delay_ms(1);
P2=0xc0;
P0=0x80;
P2=0x1f;
P0=0xff;
P2=0xe0;
P0=smg_du_tab[ba];
P2=0x1f;
P0=0x00;
delay_ms(1);
}
|