新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 74LS595串入并出應用

74LS595串入并出應用

作者: 時間:2016-11-17 來源:網絡 收藏
C代碼:

/*************** writer:shopping.w ******************/
#include
#include
#define uint unsigned int
#define uchar unsigned char

本文引用地址:http://butianyuan.cn/article/201611/315534.htm

sbit SH_CP = P2^0;
sbit DS = P2^1;
sbit ST_CP = P2^2;
uchar temp;
uchar code DSY_CODE[]=
{
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90
};

void Delay(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}

void In_595()
{
uchar i;
for(i=0;i<8;i++)
{
temp <<= 1;
DS = CY;
SH_CP = 1;
_nop_();
_nop_();
SH_CP = 0;
}
}

void Out_595()
{
ST_CP = 0;
_nop_();
ST_CP = 1;
_nop_();
ST_CP = 0;
}

void main()
{
uchar i;
while(1)
{
for(i=0;i<10;i++)
{
temp = DSY_CODE[i];
In_595();
Out_595();
Delay(200);
}
}
}



關鍵詞: 74LS595串入并

評論


技術專區(qū)

關閉