標(biāo)題: 數(shù)碼管動(dòng)態(tài)掃描——(可惜有點(diǎn)錯(cuò)誤但現(xiàn)在的我還無法解決) [打印本頁]

作者: nius    時(shí)間: 2015-4-10 03:11
標(biāo)題: 數(shù)碼管動(dòng)態(tài)掃描——(可惜有點(diǎn)錯(cuò)誤但現(xiàn)在的我還無法解決)
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar aa,ss,ge,shi,rr;
sbit q1=P2^0;
sbit q2=P2^1;



uchar code shuwei[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

void time(uchar);
void main()
{
ss=13;
P0=0;
P2=0;

rr=0xff;
rr=0;
while(1)
{
shi=ss/10;
ge=ss%10;
P2=0;
P0=shuwei[ge];
P2=0;
q1=1;

time(1);
P2=rr;


P0=shuwei[shi];
P2=0;
q2=1;


time(1);
P2=rr;

}
}
void time(uchar k)
{
uchar x,y;
for(x=100;x>0;x--)
for(y=k;y>0;y--);
}





我控制的位選是P2口中的兩個(gè)端口但是P2其他口中的其他6個(gè)端口都會(huì)受其干擾
但如果在實(shí)際中不適用其他6個(gè)端口也無大礙
不完美的列程所以我還是把他當(dāng)做以后寫程序時(shí)的對(duì)照吧     當(dāng)然如果我能用到的話.........

設(shè)計(jì)者:薛羽豪








歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1