|
sbit DT=P2^2;
sbit SCK=P2^1;
void Delay__hx711_us(void)
{
_nop_();
_nop_();
}
unsigned long ReadCount()
{
unsigned long count;
unsigned char i;
DT=1;
Delay__hx711_us();
SCK=0;
count=0;
while(DT);
for(i=0;i<24;i++)
{
SCK=1;
count<<=1;
SCK=0;
if(DT)count++;
}
SCK=1;
count=count^0x800000;
Delay__hx711_us();
SCK=0;
return count;
}
unsigned long Get_Weight(void)
{
unsigned long Weight=0;
Weight = ReadCount();
Weight = (unsigned long)(Weight/400);
return Weight;
}
難道是傳感器壞了嗎?求大神求解。!
|
|