Pc off detection / Shutdown detection #301
-
Hello, I have done a little module similar to a stream deck. I have some rgb LED's that tell me in which mode i am on and some other stuff. I would like to have that LED turn off when the pc is off (or the usb has no response). Since it's a PC the 5V usb rail is always powered on, so the arduino doesn't care if the pc is on or off. I have thought about using LED_POWER from bootkeyboard. I made it work with LED_CAPS_LOCK , but with Power led it doesn't work, or I am doing something wrong with it... I have a keyboard with backlight, and the keyboard knows when the pc is off, because it shuts off the backlight, so there must be a code in the USB protocol or something that gets sent right? or is the keyboard also "pinging" the computer to know if it's on? I was thinking i could use the same thing with the arduino, I just don't know how, or what code to listen to. I'm not very advanced in programming, I took a look at the docs, and the files in the library, I found something like "if pluggedInterface", would it be possible to use something like that? From what I have seen it's in the original HID from arduino if I'm not mistaken. I also tried using the if(serial), but that only works if the serial connection is on (obvsly.). Is there a way of doing this? Basically checking if the pc is receiving it? Any help is welcome, and thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found a way to do it using "USBDevice.isSuspended()" This is exactly what I was looking for. I tried it with my laptop and it doesn't work the same when the laptop is suspended (not shutdown). But in my tower pc it works as intended. So to anyone looking for something similar: I made
Hope this helps someone! |
Beta Was this translation helpful? Give feedback.
I found a way to do it using "USBDevice.isSuspended()"
This is exactly what I was looking for. I tried it with my laptop and it doesn't work the same when the laptop is suspended (not shutdown). But in my tower pc it works as intended.
So to anyone looking for something similar:
I made
if(USBDevice.isSuspended() == true){ While (USBDevice.isSuspended() == true){ //LED OFF delay(1000); USBDevice.isSuspended(); } }
Hope this helps someone!