You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi Austin,

    You've got two choices really.

    Relay

    You can use a relay module which is basically just an electrically operated switch (and you then use digitalWrite to control that). You can then connect any two wires together, no matter what they are.

    It's a nice, easy, safe option - and it'll work for replacing almost any switch (even mains) :)

    Direct

    Or, you can use the Espruino to control the wires directly, but you need to check stuff first:

    Turn the PC off (and unplug it), get a volt meter that'll test for shorts and measure between the chassis of the computer and each one of the wires. Hopefully one of them will be a short.

    If one is actually shorted to the chassis (ground)

    Then the voltage on the reset wire is usually high, and is expecting to be shorted to ground when the button is pressed. (It might be a plan to check this with a volt meter though). All you need to do here is connect the ground (shorted) wire to GND on Espruino, and the other wire to a pin on the Espruino Board that isn't marked as 3.3v in the previous link.

    Then just type digitalWrite(MyPin, 0) to effectively 'press' the button, and it's probably best to just let the pin 'float' to 'release' the button, so just do digitalRead(MyPin).

    If one isn't ground

    This is more tricky as probably the pin is usually at Gnd, and is expecting to be pulled to 5v when the button is pressed. Turn the PC on, and use a volt meter (one side on Gnd, the other on each wire) to figure out which wire has a voltage on it (it'll hopefully be 5v or 3.3v - if it's not then maybe post back here to check) and which one doesn't.

    Then, connect Gnd of Espruino to the chassis of your PC, and connect any output pin to the wire that didn't have a voltage. You can forget about the other wire (just make sure it doesn't short to anything).

    Then, to 'press' the button, do digitalWrite(MyPin, 1), and let the pin 'float' to 'release' the button, so just do digitalRead(MyPin).

About

Avatar for Gordon @Gordon started