標(biāo)題:
這個(gè)程序?yàn)槭裁床荒苓\(yùn)行,那里錯(cuò)了
[打印本頁]
作者:
董亞偉
時(shí)間:
2015-1-6 21:40
標(biāo)題:
這個(gè)程序?yàn)槭裁床荒苓\(yùn)行,那里錯(cuò)了
#include<reg52.h>
sbit ser=P3^4;
sbit rck=P3^5;
sbit sck=P3^6;
void hc595senddata(unsigned char x);
void hc595showdata();
void delay(unsigned int a);
void main()
{
while(1)
{
P0=0xff;
hc595senddata(0xfe);
hc595showdata();
}
}
void hc595senddata(unsigned char x)
{
unsigned char i;
for(i=0;i<8;i++)
{
if((x<<i)&0x80)
{
ser=1;
}
else
{
ser=0;
}
sck=0;
delay(1);
sck=1;
}
}
void hc595showdata()
{
rck=0;
delay(1);
rck=1;
}
void delay(unsigned int a)
{
unsigned int b;
for(b=0;b<a;b++);
}
復(fù)制代碼
捕獲.PNG
(39.48 KB, 下載次數(shù): 180)
下載附件
2015-1-6 21:39 上傳
作者:
lxl2255
時(shí)間:
2015-1-7 09:14
好象延時(shí)函數(shù)有問題,再就i是數(shù)組的問題.
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1