|
500家元
偶然得到一堆米家蓝牙Mesh模组,上边是原理图,三路开关,只能打开和关闭
KEY低有效,每次开关状态翻转一次,CNT是输出引脚,
CNT=0,LED=1;CNT=1,LED=0;
我想通过一个单片机实现点动功能,初步想法是通过检测LED引脚的电平,
当开关在手机端打开时,LED=0,cnt=1,单片机检测到低电平时,延时200ms后让KEY低一次,开关就又被关闭了,从而实现点动功能,
不知道该怎么实现,或者有什么更好的方法吗?
打算用STC8G1K08A
下面是我写的,不知道对不对
- #include <INTRINS.H>
- #include <STC8G.H>
- void Delay(unsigned int xms) //@12.000MHz
- {
- unsigned char i, j;
- while(xms)
- {
- i = 16;
- j = 147;
- do
- {
- while (--j);
- } while (--i);
- xms--;
- }
-
- }
- void main()
- {
- P3M0=0x00;
- P3M1=0x00;
- P5M0=0x00;
- P5M1=0x00;
- while(1)
- {
-
- if(P54==0)
- {
- Delay(200);
- P55 = 0;
- Delay(500);
- P55 = 1;
- Delay(200);
- }
- else if(P33==0)
- {
- Delay(200);
- P32 = 0;
- Delay(500);
- P32 = 1;
- Delay(200);
- }
- else if(P31==0)
- {
- Delay(200);
- P30 = 0;
- Delay(500);
- P30 = 1;
- Delay(200);
- }
- else
- {
-
- }
- }
- }
复制代码
|
|