Answer the question
In order to leave comments, you need to log in
How to simulate "pressing" a switch button?
I'm trying to make a "smart home", I took up the switch (the switch will be connected to the radio module), for this I bought a proximity switch (two-button) from the Chinese , as far as I could understand with my meager knowledge of electronics, the switch uses a capacitive sensor (although I I'm still not sure). I found how to read the current state of the switch, but I could not find a way to "press" the button. I tried to give +, to each leg of the microcontroller, but it does not work. Please tell me, what are the options for simulating pressing?
Rear side of the switch
Front side of the switch
Answer the question
In order to leave comments, you need to log in
It seems to have found a solution (I'm not sure, because by the current moment the pic16f690 microcontroller is barely alive and buggy, after I accidentally applied 12 volts to it). I studied the circuit with an oscilloscope, and in this place , I got this picture:
Turn-on moment + noise (normal state):
Noise:
after which I came to the conclusion that the "button" works if a similar signal is applied to the MK leg. I sketched a simple "turn-on" on the arduino, which works every other time (apparently because of the deceased MK).
void setup() {
pinMode(10, OUTPUT);
pinMode(2, INPUT);
}
int buttonState = 0;
void loop() {
buttonState = digitalRead(2);
if (buttonState == HIGH) {
digitalWrite(10, HIGH);
delayMicroseconds(2);
digitalWrite(10, LOW);
delayMicroseconds(2);
}
}
Also asked this question. These switches are radio controlled. And on the board there is a connector for the radio. One of the contacts is RX.
If you are using arduino:
int txPin = 9; // pin connected to RF transmitter
int i; // counter to send command pulses
int pulse; // count pulse repetitions
int incomingByte = 0; // for incoming serial data
// hard coded commands (see txButton): 1 - pulse start, 2 - zero, 3 - one, 4 - pause, 5 - low
int button1[45]={44, 1, 2, 4, 2, 4, 2, 4, 3, 5, 2, 4, 2, 4, 3, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2};
int button2[43]={43, 1, 2, 4, 2, 4, 2, 4, 3, 5, 2, 4, 2, 4, 3, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 3, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2};
int button3[41]={40, 1, 2, 4,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 2, 5, 2, 4, 3, 4, 2, 4, 2, 4, 2};
int button11[41]={40, 1, 2, 4, 2, 4, 2, 4, 3, 5, 2, 4, 2, 4, 3, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 5, 3, 4, 2, 5, 2, 4, 3, 4, 2};
void setup () {
pinMode(txPin, OUTPUT);
Serial.begin(9600);
Serial.println("Number = button; a to press 0; b to shut off all");
}
void loop(){
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
switch(incomingByte) {
case 49:
txButton(button1);
Serial.println("Switching on 1");
break;
case 50:
txButton(button2);
Serial.println("Switching on 2");
break;
case 51:
txButton(button3);
Serial.println("Switching on 3");
break;
case 52:
txButton(button4);
Serial.println("Switching on 4");
break;
case 53:
txButton(button5);
Serial.println("Switching on 5");
break;
case 54:
txButton(button6);
Serial.println("Switching on 6");
break;
case 55:
txButton(button7);
Serial.println("Switching on 7");
break;
case 56:
txButton(button8);
Serial.println("Switching on 8");
break;
case 57:
txButton(button9);
Serial.println("Switching on 9");
break;
case 97:
txButton(button10);
Serial.println("Switching on 0");
break;
case 98:
txButton(button11);
Serial.println("Switching All off");
break;
}
} // end if serial available
}// end void loop
// transmit command. Due to transmitter (or something, I don't know) transmission code should be INVERTED. Ex: one is coded as LOW-delay->HIGH instead of HIGH-delay-LOW
void txButton(int cmd[]) {
Serial.print("Processing. Array size is ");
Serial.println(cmd[0]);
digitalWrite(txPin, HIGH); // not sure if its required, just an attempt to start transmission to enable AGC of the receiver
delay(1000);
for (pulse= 0; pulse <= 100; pulse=pulse+1) { // repeat command 100 times
for (i = 1; i < cmd[0]+1; i = i + 1) { // transmit command
switch(cmd[i]) {
case 1: // start
digitalWrite(txPin, HIGH);
delayMicroseconds(550);
digitalWrite(txPin, LOW);
// Serial.print("s");
break;
case 2: // "zero", that is short high spike
digitalWrite(txPin, LOW);
delayMicroseconds(110);
digitalWrite(txPin, HIGH);
// Serial.print("0");
break;
case 3: // "one", that is long high spike
digitalWrite(txPin, LOW);
delayMicroseconds(303);
digitalWrite(txPin, HIGH);
// Serial.print("1");
break;
case 4: // pause, that is short low spike
digitalWrite(txPin, HIGH);
delayMicroseconds(110);
digitalWrite(txPin, LOW);
// Serial.print("p");
break;
case 5: // low, that is long low spike
digitalWrite(txPin, HIGH);
delayMicroseconds(290);
digitalWrite(txPin, LOW);
// Serial.print("l");
break;
}
}
}
}
from the photos you can see that it has a connector for control, you need to find documentation for this switch and see which pin is responsible for what. Giving + to each leg is a very, very bad idea, depending on how exactly it happened, there is a chance that the controller is now dead.
According to the link you gave, it is written in large letters that the switch is capacitive)
Judging by the removal of the front part on the board, there are two areas for touching. If it’s not very good with electronics, then look where the conductors come to the controller and use a multimeter to see the voltage change at the moment the touch panel is touched (do not forget about TB).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question