再來張合影

自己寫的擴展板的上位機軟件
========================= 測 試 程 序 ========================
#include <reg52.h>
sbit st=P1^5; // 存儲脈沖 該脈沖上升沿所有被所存的信號一起輸出
sbit sh=P1^6; // 移位脈沖 該脈沖上升沿輸出信號移位,但不一定輸出
sbit DA=P1^7; // 待移入的數據信號
sbit oe_595=P3^6; // 595使能端
sbit oe_138=P1^4; // 138使能端
unsigned char code zf[4][32]= //從左到右 從上到下 橫向8點右高位
{
0x00,0x10,0xFE,0x3F,0x80,0x00,0x80,0x00, //"正"
0x80,0x00,0x80,0x00,0x88,0x08,0x88,0x1F,
0x88,0x00,0x88,0x00,0x88,0x00,0x88,0x00,
0x88,0x00,0x88,0x20,0xFF,0x7F,0x00,0x00,
0x40,0x00,0x40,0x00,0x40,0x20,0xFF,0x7F, //"在"
0x20,0x00,0x20,0x02,0x10,0x02,0x10,0x0A,
0xC8,0x1F,0x0C,0x02,0x0A,0x02,0x09,0x02,
0x08,0x02,0x08,0x22,0xE8,0x7F,0x08,0x00,
0x00,0x00,0x02,0x22,0xE4,0x27,0x24,0x2A, //"測"
0xA1,0x2A,0xA6,0x2A,0xA4,0x2A,0xB0,0x2A,
0xA8,0x2A,0xA4,0x2A,0xA7,0x2A,0x84,0x20,
0x44,0x21,0x24,0x22,0x14,0x2A,0x04,0x10,
0x00,0x04,0x02,0x14,0x04,0x24,0x04,0x04, //"試"
0xF0,0x7F,0x00,0x04,0x07,0x04,0xE4,0x07,
0x84,0x04,0x84,0x08,0x84,0x08,0x84,0x08,
0x94,0x4B,0xEC,0x48,0x44,0x50,0x00,0x20
};
void Delay(unsigned int i) // 延時函數
{
while(--i)
;
}
void SendByte(unsigned char Dat) // 對595寫入一個字節數據
{
unsigned char a;
for(a=0;a<8;a++) // 分8次移位輸出到鎖存器
{
if((Dat&0x80)==0x80) // 判斷寫0還是寫1
{ DA=1; }
else
{ DA=0; }
sh = 0;
st = 0;
sh = 1; // SH上升沿所存移位輸出信號
st = 1; // ST上升沿輸出鎖存數據
Dat=Dat<<1; // 數據移一位
}
}
void main(void) // 主程序
{
oe_595=0;oe_138=1; // 初始化 開595 關138
while(1)
{unsigned char i;
for(i=0;i<16;i++) // 共計16次,因為共有16行要掃描
{
SendByte(zf[0][i*2]);
SendByte(zf[0][i*2+1]);
SendByte(zf[1][i*2]);
SendByte(zf[1][i*2+1]);
SendByte(zf[2][i*2]);
SendByte(zf[2][i*2+1]);
SendByte(zf[3][i*2]);
SendByte(zf[3][i*2+1]); // 送某行的8列顯示數據
P1=i; // 送掃描碼
oe_138=0; // 開138 顯示該行數據
Delay(100); // 延時一會
oe_138=1; // 關138
}
}
}
=========================== 《 完 》 ==========================
薛二煒 于福建·寧德
2012 年 11 月 10 日