//另外线性效果也不是很理想,但是能够满足一般的要求了
#i nclude " reg51.h "
#i nclude " absacc.h "
#define LSB 0x01
#define HIGH 1
#define LOW 0
#define BUZZER_OFF BUZZER=1
sbit DS1868_RST=P3^5; //pin 5
sbit DS1868_CLK=P3^6; //pin 6
sbit DS1868_DQ =P3^7; //pin 8
sbit BUZZER=P0^4;
void DS1868_communication(unsigned char potentiometer_1,unsigned char potentiometer_0);
void main(void)
{
BUZZER_OFF;
while(1)
{
DS1868_communication(0x55,0x55);
}
}
void DS1868_communication(unsigned char potentiometer_1,unsigned char potentiometer_0)
{
unsigned char i;
bit stack=1;
DS1868_RST=HIGH;
DS1868_DQ = stack;
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
for(i=0;i<8;i++)
{
DS1868_DQ=(bit)(potentiometer_1&LSB);
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
potentiometer_1>>=1;
}
for(i=0;i<8;i++)
{
DS1868_DQ=(bit)(potentiometer_0&LSB);
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
potentiometer_0>>=1;
}
DS1868_RST=LOW;
}
『本文转载自网络,版权归原作者所有,如有侵权请联系删除』