#include<reg52.h> //52系列單片機(jī)頭文件 #define uchar unsigned char #define uint unsigned int uint x,y; uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; //共陰極數(shù)碼管編碼 void display(uchar,uchar,uchar,uchar); //聲明子函數(shù) void delay(int); //聲明子函數(shù) void main() { while(1) { display(1,2,3,4); //主程序始終調(diào)用數(shù)碼管顯示子程序 } } void display(uchar a,uchar b,uchar c,uchar d) { P2=0xef; P0=table[a]; //給第一個(gè)數(shù)碼管送"a" delay(1); //延時(shí)1ms P2=0xdf; P0=table; //給第二個(gè)數(shù)碼管送"b" delay(1); //延時(shí)1ms P2=0xbf; P0=table[c]; //給第三個(gè)數(shù)碼管送"c" delay(1); //延時(shí)1ms P2=0x7f; P0=table[d]; //給第三個(gè)數(shù)碼管送"d" delay(1); //延時(shí)1ms } void delay(uint z) //延時(shí)子函數(shù) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } 我不懂每個(gè)‘’P2=‘’的意思 還有那個(gè)定義的 abcd是不是對(duì)應(yīng)的就是 uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; 這里面的前4個(gè) |