many mac keyboards have a power button. Is there a way to mimic this power button shortcut from an arduino?
Asked
Active
Viewed 909 times
0
-
3Perhaps you could be clear what you mean by "mimic". Do you want your Arduino to be able to turn on (or off) your Mac without manual intervention? – Greg Hewgill Jul 02 '14 at 20:57
-
2Also, what keyboard? Some Mac laptops have a power button for the computer, where others have one to shut off the wireless keyboard. – Anonymous Penguin Jul 02 '14 at 21:21
-
You have to research HID keyboard codes and its protocol. The power button is a regular key on the keyboard with a specific key code and specific a data frame. Leonardo can probably do it, most somewhat older design Arduino's can't act as a USB HID. – jippie Jul 03 '14 at 05:04
-
The Arduino can emulate a keyboard from which you can send a series of keystrokes to turn off the computer. Not sure you'll be able to mimic the hardware button. There are a few questions that are related: http://arduino.stackexchange.com/search?q=hid+is%3Aquestion – sachleen Jul 03 '14 at 16:47
-
I have a mac mini rack holder that has a front panel with power button. It connects and controls the mac mini with USB only. I want to replicate this power signal sent over the USB with an arduino instead. – Brian Jul 03 '14 at 20:08
-
@Brian you'll have to try connecting that USB device to another OS (that most likely won't respond to the press) and use some kind of keylogging software to detect what character code it sends to the computer. If you can figure that out, it's easy to do this on the Leonardo (although still possible on the Uno, but a bit harder). – Anonymous Penguin Jul 04 '14 at 00:53
1 Answers
2
There are multiple ways to do that.
You could use an Arduino Leonardo as a keyboard, then send a shortcut command to shut down or sleep the computer. You can edit these from System Preferences>Keyboard>Shorcuts>Services. The keycode 0x66 does not work for mac, but may for other operating systems source
You could write a small program (I'd do it in Python) which communicates with the Arduino over the serial port and shuts down the Mac if the Arduino wants it to.
You could sacrifice an USB keyboard and use a relay to "press" the power key.