|
/* 输入输出在主函数里 */
#include<reg52.h>
//#include<intrins.h> /*_nop_()在<intrins.h>里*/
#define uchar unsigned char
#define uint unsigned int
sbit shcp=P2^0;
sbit ds=P2^1;
sbit stcp=P2^2;
uchar temp;
uchar code duan[]=
{0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x10};
/*延时*/
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
/*数据输入 */
void input(uchar temp)
{
uchar i;
for(i=0;i<8;i++) /*只是表明向左移动 移动过次*/
{
temp<<=1;
ds=CY;
shcp=0;
shcp=1;
//_nop_();
//_nop_();
}
}
/*数据输出*/
void output()
{
stcp=0;
//_nop_();
stcp=1;
// _nop_();
//stcp=0;
}
/*主函数*/
void main(void)
{
uchar i;
while(1)
{
for(i=0;i<10;i++)
{
temp=duan;
input(temp);
output();
delay(300);
}
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|