谁懂74hc595和165的51c程序,求帮忙
谁懂74hc595和165的51c程序,求帮忙主函数不会写,595和165不懂怎么写,就是从网上看了一点代码也不是很懂。谁帮帮忙写下主函数啊,就是1个按键控制1个灯,求帮...
谁懂74hc595和165的51c程序,求帮忙主函数不会写,595和165不懂怎么写,就是从网上看了一点代码也不是很懂。
谁帮帮忙写下主函数啊,就是1个按键控制1个灯,求帮忙!!!!
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DAT[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
sbit SCLK_595 =P2^2;
sbit SDATA_595 =P2^1;
sbit RCK_595 =P2^3;
sbit HC165_nPL = P2^4;
sbit HC165_CLK = P2^6;
sbit HC165_OUT =P2^5;
sbit hc165_clkin =P2^7;
uchar temp;
unsigned char bdata Key;
sbit K0=Key^0;
sbit K1=Key^1;
sbit K2=Key^2;
sbit K3=Key^3;
sbit K4=Key^4;
sbit K5=Key^5;
sbit K6=Key^6;
sbit K7=Key^7;
void delay(int i)
{
int j;
while(i--)
for(j=255;j>0;j--);
}
unsigned long HC165_Init(void)
{
unsigned char i;
unsigned int indata;
HC165_nPL=0;
_nop_();
HC165_nPL=1;
_nop_();
indata=0;
for(i=0; i<8; i++)
{
indata=indata<<1;
if(HC165_OUT==1)
indata=indata+1;
HC165_CLK=0;
_nop_();
HC165_CLK=1;
}
return(~indata);
}
void HC595_Init()
{
uchar j;
for (j=0;j<8;j++)
{
temp=temp<<1 ;
SDATA_595=CY;
SCLK_595=1;
_nop_();
_nop_();
SCLK_595=0;
}
RCK_595=0;
_nop_();
_nop_();
RCK_595=1;
}
void main()
{
hc165_clkin=0;
SCLK_595=0;
RCK_595 =1;
while(1)
{
}
} 展开
谁帮帮忙写下主函数啊,就是1个按键控制1个灯,求帮忙!!!!
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code DAT[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
sbit SCLK_595 =P2^2;
sbit SDATA_595 =P2^1;
sbit RCK_595 =P2^3;
sbit HC165_nPL = P2^4;
sbit HC165_CLK = P2^6;
sbit HC165_OUT =P2^5;
sbit hc165_clkin =P2^7;
uchar temp;
unsigned char bdata Key;
sbit K0=Key^0;
sbit K1=Key^1;
sbit K2=Key^2;
sbit K3=Key^3;
sbit K4=Key^4;
sbit K5=Key^5;
sbit K6=Key^6;
sbit K7=Key^7;
void delay(int i)
{
int j;
while(i--)
for(j=255;j>0;j--);
}
unsigned long HC165_Init(void)
{
unsigned char i;
unsigned int indata;
HC165_nPL=0;
_nop_();
HC165_nPL=1;
_nop_();
indata=0;
for(i=0; i<8; i++)
{
indata=indata<<1;
if(HC165_OUT==1)
indata=indata+1;
HC165_CLK=0;
_nop_();
HC165_CLK=1;
}
return(~indata);
}
void HC595_Init()
{
uchar j;
for (j=0;j<8;j++)
{
temp=temp<<1 ;
SDATA_595=CY;
SCLK_595=1;
_nop_();
_nop_();
SCLK_595=0;
}
RCK_595=0;
_nop_();
_nop_();
RCK_595=1;
}
void main()
{
hc165_clkin=0;
SCLK_595=0;
RCK_595 =1;
while(1)
{
}
} 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询