您现在的位置: 主页 > MCU > 单片机技术应用 > ds1868(数字电位器) c 驱动程序 -
本文所属标签:
为本文创立个标签吧:

ds1868(数字电位器) c 驱动程序 -

来源: 网络用户发布,如有版权联系网管删除 2018-09-06 

[导读]****************DS1868 数字字电位器调试******************/
//注意:ds1868的管脚 调试是我用P2口的 5、6、7 脚 发现不好用//另外线性效果也不是很理想,但是能够满足一般的要求了#i nclude " reg51.h "
#i n

****************DS1868 数字字电位器调试******************/
//注意:ds1868的管脚 调试是我用P2口的 5、6、7 脚 发现不好用

//另外线性效果也不是很理想,但是能够满足一般的要求了

本文引用地址: http://www.21ic.com/app/mcu/201808/787312.htm

#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;
}



              查看评论 回复



嵌入式交流网主页 > MCU > 单片机技术应用 > ds1868(数字电位器) c 驱动程序 -
 

"ds1868(数字电位器) c 驱动程序 -"的相关文章

网站地图

围观()