标题:
51单片机STC8A+TTP229B 16键电容按键的源码与视频演示
[打印本页]
作者:
pengwu1207
时间:
2018-6-4 09:55
标题:
51单片机STC8A+TTP229B 16键电容按键的源码与视频演示
【51单片机】STC8A+TTP229B 16键电容按键
视频如下:
https://weibo.com/2419242361/GgSSbkADZ
代码超级简单:
unsigned int TTP229B(void)
{ unsigned char i;
unsigned int temp=0x0000;
SDA=0;
SCL=0;
Delay1us(93);
SDA=1;
Delay1us(12);
SDA=0;
//Delay1us(25);
P6M0=0X00;
P6M1=0X02;
SCL=1;SCL=0;
for(i=0;i<16;i++) {
SCL=1;
if(SDA==1) {temp|=(1<<i); }
SCL=0;
}
P6M0=0X00;
P6M1=0X00;
Delay1ms(2);
return temp&0xFFFF;
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1