Can an Arduino UNO and Arduino Leonardo do the same things?

Some of the examples in the Arduino software say to use Leonardo e.g. KeyboardMessage.


No, the Uno and the Leonardo cannot do the same thing. The Leonardo is a single MCU directly connected to the USB port. It is down to the software on that MCU as to how it communicates (what it enumerates as) on the USB bus.

The Uno, conversely, is a dual MCU system. It has the "main" MCU (the ATMega328P) which is what you program, and that communicates to the USB port via another MCU. The two MCUs are connected using TTL RS-232 (UART), so the only communication you have with your computer is through the Serial object.

There are benefits and problems with both approaches. The benefits of the Leonardo are that you can emulate keyboards, mice, etc. The down side is that the whole USB communication is more fragile and is at the mercy of the user. The Uno's benefits are that the USB serial is always connected and available regardless of the state of the main MCU, which is much more friendly from the PC's point of view. The down side is that it severely limits your communication options.

| improve this answer | |

Yes you can, but not with that library. This method is a little advanced and requires you to upgrade a different type of firmware to your second MCU on your Uno.

(The full tutorial is available here)

Example code from the tutorial link shown above (for process outlined below):

uint8_t buf[8] = { 
  0 };  /* Keyboard report buffer */

void setup() 

void loop() 
  int randomChar = random(4, 130);
  long randomDelay = random(1000, 10000);


  buf[2] = randomChar;    // Random character
  Serial.write(buf, 8); // Send keypress

void releaseKey() 
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8); // Release key  

Here's what you need to do:

  1. Get a DFU programmer

    Windows: Download Atmel's flip programmer from here http://www.atmel.com/tools/flip.aspx

    Mac: Install MacPorts following these instructions: http://www.macports.org/install.php#pkg Once MacPorts is installed, in a Terminal window, type sudo port install dfu-programmer

    Linux: from a command line type sudo apt-get install dfu-programmer or sudo aptitude install dfu-programmer depending on your distribution

    (Source: http://arduino.cc/en/Hacking/DFUProgramming8U2)

  2. Download the Keyboard LUFA firmware

  3. You'll have to solder a resistor on a non-SMD Uno (that's outlined in the Arduino link in the second step)

  4. Connect the Uno to your comptuer and reset the 8u2 (short the farthest left pair of metal contacts in the upper left hand corner of the Uno)

  5. Upload the firmware using the GUI in flip, OR for Mac/Linux go to the directory where the firmware is using the terminal then:

Type this line (Still, Mac or Linux only):

sudo dfu-programmer at90usb82 erase
sudo dfu-programmer at90usb82 flash [Replace-this-with-file-name].hex
sudo dfu-programmer at90usb82 reset

Unplug/plug in your board and enjoy! Note: you'll have to flash the standard firmware to upload a new sketch and the flash the keyboard firmware again to get this to work.

| improve this answer | |

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.