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.
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.
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()
{
Serial.begin(9600);
randomSeed(analogRead(0));
delay(200);
}
void loop()
{
int randomChar = random(4, 130);
long randomDelay = random(1000, 10000);
delay(randomDelay);
buf[2] = randomChar; // Random character
Serial.write(buf, 8); // Send keypress
releaseKey();
}
void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Release key
}
Here's what you need to do:
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
orsudo aptitude install dfu-programmer
depending on your distribution
Download the Keyboard LUFA firmware
You'll have to solder a resistor on a non-SMD Uno (that's outlined in the Arduino link in the second step)
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)
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.