I have a power outlet that is controlled by a little IC chip, which responds to a button-press. I found that by shorting the two button leads for 0.5 seconds, the chip will respond as though I had pressed the button, which is great. Now I want to control it with my Arduino. I measured the voltage across the button, which was a steady 5.05v. I put my multimeter in series with the button and got only 20-50uA while pressing it, so it's well within the Arduino's capability. I soldered a wire to each lead on the button so I can connect them to Arduino pins. However, I don't know how to mimic the function of a switch. I was thinking I could set one pin high and one low, then activate the button by setting them both low to mimic a short. Is my logic accurate? Or should I connect the positive lead to ground and the negative lead to a digital pin and activate by setting the pin high?
I figured it out!! The following code toggles the device between on and off every 5 seconds. When both pins are set LOW, a connection is made between them and it's like the button is being pushed.
int positive = 3;
int negative = 4;
void setup() {
pinMode(positive, OUTPUT);
digitalWrite(positive, HIGH);
pinMode(negative, OUTPUT);
digitalWrite(negative, LOW);
}
void loop() {
digitalWrite(positive, LOW);
delay(250);
digitalWrite(positive, HIGH);
delay(5000);
}
Just make sure that the Arduino pin is not required to source or sink more than 20 mA.
...R
Roger that and thanks!
I think, that better would be to connect only the positive pin and the other side of switch (negative) connect to ground of arduino (if they are independently powered - if they are powered from one source of DC, then you should measure all voltages again common ground )