many mac keyboards have a power button. Is there a way to mimic this power button shortcut from an arduino?

  • 3
    Perhaps 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? Jul 2 '14 at 20:57
  • 2
    Also, what keyboard? Some Mac laptops have a power button for the computer, where others have one to shut off the wireless keyboard. Jul 2 '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 3 '14 at 5: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: arduino.stackexchange.com/search?q=hid+is%3Aquestion
    – sachleen
    Jul 3 '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 3 '14 at 20:08

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.