//範例7-3C:4個7段顯示器掃描式輸出 //檔名:ch7C_3.C #include unsigned char code seg7[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned char code scanline[]={0xf7,0xfb,0xfd,0xfe} ; void delay1ms(int count); main() { char i; while(1){ for(i=0;i<4;i++){ P1=0xff ; //關閉共陽 P0=seg7[i] ; //輸出資料 P1=scanline[i] ; //選擇輸出位置 delay1ms(1) ; //時間延遲副程式 } } } void delay1ms(int count) { int i,j; for(i=0;i