//===============================================
//程序:74HC165 并入串出程序
//署名:张合伟
//QQ :476580555
//邮箱:476580555@qq.com
//===============================================
#include "at89x52.h"
#define uchar unsigned char
#define HC165_CLK P3_1
#define HC165_SL P3_3
#define HC165_Data P3_2
uchar Read_74HC165(void)
{
uchar Temp_Data,i;
HC165_SL=0; //数据锁存无效
HC165_SL=1; //允许移位输出
Temp_Data=0;
for(i=0;i<8;i++)
{
Temp_Data<<=1;
if(HC165_Data==1)
{
Temp_Data|=0X01;
}
HC165_CLK=0;
HC165_CLK=1;
}
return Temp_Data;
}
void main()
{
while(1)
{
P1=Read_74HC165();
}
}
欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) | Powered by Discuz! X3.4 |