How best to shut down a PC using an external switch?

I am the proud owner of this emergency stop button:

It has one NO and one NC contact. Of course, there are two connection options each at 1 and 2, and at 3 and 4.

I want to do something with it now, but since I obviously don't want to use it to access the mains voltage, I thought it would be nice if I could use it to shut down my PC.

I thought maybe you could connect something like an Arduino or something similar to the switch and one of the USB ports on the PC, which would then give the PC the command to shut down.

Is that too complicated?

Of course, I also want to keep it relatively inexpensive. And using an Arduino just to issue a single command seems pretty wasteful to me.

That's why I wanted to ask the IT and electronics professionals here how it can best be implemented.

To help you better understand my skills: No experience with Arduino; I can handle simple programming; 1st year electrical engineering apprentice

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
18 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Commodore64
1 year ago

Even if the Arduino is “too bad” to set a command, other hardware is more expensive and is complicated.

If you take an Arduino with “U4”, then you can register as a USB device on the PC and become a USB device.

As a keyboard, the “multimedia button” can then send down.

It’s not easier. Power comes via the USB cable, turn off button is also sent via this cable.

https://www.amazon.de/LAFVIN-Atmega32U4-Development Microcontroller-Compatible/dp/B0CQP3V416

You can also send mouse commands simultaneously. With a poti and foot pedal you can also program an Autoclicker in it.

You can start the emergency out and then expand later.

Commodore64
1 year ago
Reply to  Commodore64

P.S.:

Here’s what you have to do:

https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardwrite/

Note the link “Hotkeys”.

You can almost take the example. You just have to make sure that the fully pressed emergency exit is permanently on (or off).

You have to ask, so wait until the switch is pulled out. This can be done in a simple loop. So run as long as the switch is inside. Once he’s pulled out, the program goes on. So he’s waiting for that to press in.

To go down there is a special multimedia button, unfortunately I do not find it in the Arduino Hotkey table.

There’s something else you need to investigate how to send the code of this button.

But it also goes with “Win-X” and then “U” “U” – if I remember correctly. The sequence can easily send the Arduino. As a Linuxuser, I can’t try this right now.

RareDevil
1 year ago

I thought you might connect something like an Arduino or the like to the switch and one of the USB ports of the PC, which then gives the PC the command to shut down.

In principle, this would be possible. You need to send a command via the Arduino via Serialport to a software that permanently monitors this serial interface, i.e. always running in the background, and then forwards the switch-off command to Windows. Such methods are, for example, USVen standard, so that the PC is automatically driven down when the network fails, before the USV is empty and the system crashes…

RareDevil
1 year ago
Reply to  RareDevil

Alternatively, the arduino can also give a switch-off pulse parallel to the housing probe via a relay when the emergency switch is actuated, so that no software is needed in the background. Then you could even monitor USB power, and if USB power falls away, switch off the power supplies with 10 seconds delay via relay. If you pull out the emergency, you can even let the Arduino turn on the power supply and initiate the computer start with delay. Because it would already be connected to the housing knob and can also give a switch-on pulse. There are many possibilities. Depends on the skills and how far you want to drive it…

VINC767
1 year ago

Simple. You don’t want to make your PC always hard, but let it go down to the button when printing. Otherwise, this may eventually lead to data loss.

Your motherboard has two pins that go to the case power button. Use the ;). Since the emergency exit is not a pushbutton but a switch and therefore remains in the closed position, you should either pick up a pushbutton or build an external circuit to realize your project. Because letting down is the same as when you pull the plug. For example, you can realize this to the Arduino in between.

Ginpanse
1 year ago

your pc already has such a taster. just in parallel to it.

RareDevil
1 year ago
Reply to  Ginpanse

The emergency exit does not give a pulse, but a continuous signal. If the PC needs longer than 4sec, a hard command is set by Bios and data loss can occur…

Ginpanse
1 year ago
Reply to  RareDevil

that’s logical. then he has to turn him off again.

Ginpanse
1 year ago

if you want to make it more interesting, get a wemos d1 mini with battery shield and nem battery (don’t care about the world) and build it in the case from the not-off. then you can program a wifi switch.

Ginpanse
1 year ago

that would be the most sensible method correct.

Ginpanse
1 year ago

then get you nen attiny or esp8266. arduino is clobular and extremely overpriced. sometimes gives arduino nano clones on aliexpress. they do too.

RareDevil
1 year ago

Well, 4sec have been a long time ago. Press and pull again… That would be possible or remove the lock that he only works like a button… Then you don’t even have to think about it… If in this function, then also as start probe. This would be the most expensive method without Arduino. With Arduino you could go a lot further…

Ginpanse
1 year ago

not really.

michele1450
1 year ago

The Not Aus is a switch you notice quickly because you have to do extra. Taster immediately returns after release. With the Arduino should go like this, there are also some leads on the internet. So you’ll find something googlen there and how it’s done.

MarSusMar
1 year ago
Reply to  michele1450

Yes googlen should be raised to school….