I want to know if it is possible to use an arduino to tell a pc which os to boot to. I know It is possible to turn on the pc by wiring it to the motherboard pins with the power switch, and I know the arduino I have (http://www.amazon.com/SainSmart-ATmega328P-Development-Compatible-Arduino/dp/B00E5WJSHK/ref=sr_1_1?ie=UTF8&qid=1436368217&sr=8-1&keywords=sainsmart+uno+r3) can act as a mouse or keyboard. Can that be done before the pc has booted however?

  • "can act as a mouse or keyboard" Do you know how to make it do so, or have you heard that others can do it? Jul 8, 2015 at 15:21
  • There's a hackaday article on using the board's AT16u2 to emulate an HID device. Jul 8, 2015 at 15:44
  • 1
    Injecting key events should be do-able, the question may be more if what needs to be injected and when is context- dependent. Why not use a customizeable boot manager like grub, and modify it to talk to you over a serial port? Jul 8, 2015 at 16:55
  • Arduino Micro, or Arduino Leonardo would be a lot easier to emulate a keyboard. Since you want the arduino to power up the PC you'd connect it to the 5v-standy (usb will power down in some PCs, so you can't usb to power it. I don't see how this would not be possible. You could use the old power button to control the arduino. Something like, one press=>Boot Windows, two presses =>Boot Linux etc.
    – Gerben
    Jul 8, 2015 at 17:59
  • Ignacio- I have never used an arduino for more than a motor and sensor controller, but the documentation says that It can emulate a HID device. Jul 9, 2015 at 21:41

1 Answer 1


So it might depend on how you implement it. With an Arduino Uno, your options for creating an HID device are limited to either reprogramming the 16u2 (which will require an ISP) or using a software USB implementation (like V-USB). If you go with the first method I'm pretty sure that will work as it will be a native USB connection. As for the second method, I'm not sure how well V-USB responds to having the USB host turning on while it is running. The best thing to do is just try it and see how well it works.

The bigger challenge you will run into is being able to select your PC operating system. Because this will be a one way connection, there is no way of knowing what state the computer is in and whether or not it is time to press a key yet or not. This means you will have to be timing things fairly accurately, which can be tricky unless you are careful. The internal oscillator is not very accurate (but probably still accurate enough) and interrupts used for communicating with USB can block the main loop. That is not to mention any variations the computer might have in its boot process.

A good alternative method would be to set up a bootloader on your PC that can be controlled via a serial port. GRUB2 is a popular one that does support a serial console. All you would need to do is add a level adjuster to adapt the Arduino UART to RS232, then set up the code to wait for the GRUB prompt and then send the command necessary to select which OS you wish to use.

  • Thanks for the information. This is very helpful and a great place to start. Grub sounds like the way to go. I have used grub in the past, but no more than using the arrow keys to select the os. The arduino's would send the power signal to the computers to boot, and then feed the bootloader the information telling it what to boot to? The serial console is via usb? How could I do this on two separate machines at the same time? Is it the same type of thing as using the serial console to monitor the arduino through the arduino++ software? Jul 9, 2015 at 21:40
  • The arduino would listen to the serial port and wait for grub to be ready, usually it does this by printing a prompt (e.g. traditionally this has been "grub>" not super sure about newer versions though). If these computers have actual serial ports (i.e. 9 pin DSUB RS232) I would try and use that and connect to it via the UART port on the Arduino, using an adapter like I mentioned. Using the USB serial port might be possible, but it just depends on whether GRUB supports them.
    – Jake C
    Jul 9, 2015 at 22:35
  • As far as multiple computers go, you would pretty much have to go the UART route and get an Arduino that has more than one UART. For example the Due and the Mega 2560 have 4. Other Arduino-like boards like the Teensy 3.1 also offer extra UARTs.
    – Jake C
    Jul 9, 2015 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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