電路圖:
PDG2 如電路圖 設定 將 P91~P94 與 P70~P76 設為 OUTPUT
(小數點暫時不用)
程式概述:
將七段顯示器點亮,然後可以改單的改變七段顯示器的數字
// 0 1 2 3 4 5 6 7 8 9
int ssc[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
// 3 2 1 0
int chan[4]={0xef,0xf7,0xfb,0xfd};
// 3 2 1 0
int time[4]={0,0,0,0}; //只要改變 矩陣內的內容即可改變顯示
void main(void)
{
int i,d;
R_PG_IO_PORT_Set_P7();
R_PG_IO_PORT_Set_P9();
while(1)
{
//更新 七段
for(i=0;i<4;i++){
R_PG_IO_PORT_Write_P7(0xff); //關掉全部
R_PG_IO_PORT_Write_P7(~ssc[time[i]]);
R_PG_IO_PORT_Write_P9(chan[i]);
for(d=0;d<1000;d++); // Delay 如果有殘影 將d的值調大
}
}
}
沒有留言:
張貼留言