Guide.ArduinoLeonardo History

Hide minor edits - Show changes to output

July 24, 2013, at 05:29 PM by Roberto Guido - redirect to new Leonardo and Micro tutorial page
Changed lines 1-109 from:
!!Guide to the Arduino Leonardo

To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.

(:*toc:)

!!!! '''Differences from the Arduino Uno'''

In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences.

!!! Single processor for sketches and USB communication.

The Leonardo differs from previous Arduino boards in that it uses a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains established regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.

!!! Serial re-enumeration on reset.

Since the Leonardo does not have a dedicated chip to handle serial communication, it means that the serial port is '''virtual''' -- it's a software routine, both on your operating system, and on the Leonardo itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the Leonardo creates a serial instance whenever it runs its bootloader. The Leonardo is an instance of USB's '''Connected Device Class (CDC)''' driver.

This means that every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.

!!! No reset when you open the serial port.

Unlike the Arduino Uno, the Leonardo doesn't restart your sketch when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.

This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open after calling Serial.begin():

(:source lang=arduino tab=4 :)
Serial.begin(9600);
// while the serial stream is not open, do nothing:
while (!Serial) ;
(:sourceend:)


!!! Keyboard and mouse emulation.

One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual serial port to your operating system (also called CDC) for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See the "Good Coding Practice" section below for a warning about using this functionality.

!!! Separation of USB and serial communication.

On the Leonardo, the main '''Serial''' class refers to the virtual serial driver on the Leonardo for connection to your computer over USB. It's not connected to the physical pins 0 and 1 as it is on the Uno and earlier boards. To use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)

!!! Differences in pin capabilities.

The Leonardo has some slight differences in the capabilities and assignments of various pins (especially for SPI and TWI). These are detailed on the [[Main/ArduinoBoardLeonardo | hardware page]].

!!!! '''Installing Drivers for the Leonardo'''

!!! OSX
*The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. There's nothing to configure with the Leonardo, so you can close this dialogue by clicking the red button in the top left of the window.

Attach:OSXKeyboardNotification.png

!!! Windows (tested on XP and 7)\\

The process for Windows XP and Windows 7 is similar. These screenshots are from an XP installation. \\

*Plug in your board and wait for Windows to begin its driver installation process. If the installer does not launch automatically, Navigate to the Windows Device Manager (Start>Control Panel>Hardware) and find the Arduino Leonardo listing. Right click and choose '''Update driver'''.
*If prompted to search for drivers online, choose "No, not this time". And click '''Next'''
Attach:LeonardoWindowsDrivers1.png
*When asked to install automatically or from a specific location, select "Install from a list or specific location" and press '''Next'''
Attach:LeonardoWindowsDrivers2.png
*Choose "Search for the best driver in these locations", and check the box "incude this location in the search". Click the '''Browse''' button and navigate to your Arduino 1.0.1 or later installation. Select the '''drivers''' folder an click '''OK'''
Attach:LeonardoWindowsDrivers3.png
*Click '''Next'''
*You will receive a notification that the Leonardo has not passed Windows Logo testing. Click on the button '''Continue Anyway'''
Attach:LeonardoWindowsDrivers5.png
*After a few moments, a window will tell you the wizard has finished installing software for Arduino Leonardo. Press the '''Finish''' button

!!! Linux\\

There is no need to install drivers for Ubuntu 10.0.4


!!!! '''Uploading Code to the Leonardo'''

In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Click the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch.

However, because the Leonardo's serial port is virtual, it disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.

These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated when the computer opens the Leonardo's serial port at 1200 baud and then closes it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)

!!!! '''Good Coding Practice With the Leonardo'''

'''A word of caution on using the Leonardo as a Mouse or Keyboard''': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system to turn this functionality on, like a physical switch or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.

'''Using the serial monitor effectively''': Since serial is going through only one processor on the Leonardo, the board is capable of filling your computer's serial buffer faster than the Uno or earlier boards. You may notice that if you send serial continually, for example like this:

(:source lang=arduino :)
void loop() {
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
}
(:sourceend:)

the Serial Monitor in the IDE slows down considerably as it tries to keep up. If you encounter this, add a short delay to your loop so that the computer's serial buffer is not filled as fast. Even a millisecond delay will help:

(:source lang=arduino :)
void loop() {
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
delay(1);
}
(:sourceend:)

Serial applications using native libraries other than RXTX library read the serial buffer faster, so you may not encounter this error much outside of the Serial Monitor, Processing, or other RXTX-based serial applications

For more details on the Arduino Leonardo, see the [[Main/ArduinoBoardLeonardo | hardware page]] and the [[Reference/MouseKeyboard | Mouse and Keyboard reference pages]].
\\
\\
to:
(:redirect Guide/ArduinoLeonardoMicro :)
July 22, 2013, at 11:03 AM by Roberto Guido - minor typo. Thanks to Roger Linhart for feedback
Changed line 28 from:
Serail.begin(9600);
to:
Serial.begin(9600);
April 02, 2013, at 02:34 PM by Scott Fitzgerald -
Changed lines 25-26 from:
This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open like so:
to:
This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open after calling Serial.begin():
Added line 28:
Serail.begin(9600);
May 21, 2012, at 04:38 PM by Scott Fitzgerald -
Added line 69:
April 24, 2012, at 04:26 PM by Scott Fitzgerald -
Added line 53:
April 24, 2012, at 04:25 PM by Scott Fitzgerald -
Changed lines 7-8 from:
!!!! Differences from the Arduino Uno
to:
!!!! '''Differences from the Arduino Uno'''
Changed lines 11-12 from:
!!! '''Single processor for sketches and USB communication.'''
to:
!!! Single processor for sketches and USB communication.
Changed lines 15-16 from:
!!! '''Serial re-enumeration on reset.'''
to:
!!! Serial re-enumeration on reset.
Changed lines 21-22 from:
!!! '''No reset when you open the serial port.'''
to:
!!! No reset when you open the serial port.
Changed lines 33-34 from:
!!! '''Keyboard and mouse emulation.'''
to:
!!! Keyboard and mouse emulation.
Changed lines 37-38 from:
!!! '''Separation of USB and serial communication.'''
to:
!!! Separation of USB and serial communication.
Changed lines 41-42 from:
!!! '''Differences in pin capabilities.'''
to:
!!! Differences in pin capabilities.
Changed lines 45-47 from:
!!!! Installing Drivers for the Leonardo

!!! '''OSX'''
to:
!!!! '''Installing Drivers for the Leonardo'''

!!! OSX
Changed line 52 from:
!!! '''Windows (tested on XP and 7)'''\\
to:
!!! Windows (tested on XP and 7)\\
Changed line 67 from:
!!! '''Linux'''\\
to:
!!! Linux\\
Changed lines 71-72 from:
!!!! Uploading Code to the Leonardo
to:
!!!! '''Uploading Code to the Leonardo'''
Changed lines 79-80 from:
!!!! Good Coding Practice With the Leonardo
to:
!!!! '''Good Coding Practice With the Leonardo'''
April 24, 2012, at 04:15 PM by Scott Fitzgerald -
Changed lines 7-8 from:
!!!! 1 | Differences from the Arduino Uno
to:
!!!! Differences from the Arduino Uno
Changed lines 11-12 from:
'''Single processor for sketches and USB communication.'''
to:
!!! '''Single processor for sketches and USB communication.'''
Changed lines 15-16 from:
'''Serial re-enumeration on reset.'''
to:
!!! '''Serial re-enumeration on reset.'''
Changed lines 21-22 from:
'''No reset when you open the serial port.'''
to:
!!! '''No reset when you open the serial port.'''
Changed lines 33-34 from:
'''Keyboard and mouse emulation.'''
to:
!!! '''Keyboard and mouse emulation.'''
Changed lines 37-38 from:
'''Separation of USB and serial communication.'''
to:
!!! '''Separation of USB and serial communication.'''
Changed lines 41-42 from:
'''Differences in pin capabilities.'''
to:
!!! '''Differences in pin capabilities.'''
Changed lines 45-47 from:
!!!! 2 | Installing Drivers for the Leonardo

'''OSX'''
to:
!!!! Installing Drivers for the Leonardo

!!! '''OSX'''
Changed line 52 from:
'''Windows (tested on XP and 7)'''\\
to:
!!! '''Windows (tested on XP and 7)'''\\
Changed line 67 from:
'''Linux'''\\
to:
!!! '''Linux'''\\
Changed lines 71-72 from:
!!!! 3 | Uploading Code to the Leonardo
to:
!!!! Uploading Code to the Leonardo
Changed lines 79-80 from:
!!!! 4 | Good Coding Practice With the Leonardo
to:
!!!! Good Coding Practice With the Leonardo
April 24, 2012, at 04:10 PM by Scott Fitzgerald -
Changed lines 45-46 from:
!!! 2 | Installing Drivers for the Leonardo
to:
!!!! 2 | Installing Drivers for the Leonardo
Changed lines 71-72 from:
!!! 3 | Uploading Code to the Leonardo
to:
!!!! 3 | Uploading Code to the Leonardo
Changed lines 79-80 from:
!!! 4 | Good Coding Practice With the Leonardo
to:
!!!! 4 | Good Coding Practice With the Leonardo
April 24, 2012, at 04:09 PM by Scott Fitzgerald -
Changed lines 11-12 from:
1a | '''Single processor for sketches and USB communication.'''
to:
'''Single processor for sketches and USB communication.'''
April 24, 2012, at 04:09 PM by Scott Fitzgerald -
Changed lines 11-12 from:
1 | '''Single processor for sketches and USB communication.'''
to:
1a | '''Single processor for sketches and USB communication.'''
April 24, 2012, at 04:09 PM by Scott Fitzgerald -
Changed lines 7-8 from:
!!!! 2 | Differences from the Arduino Uno
to:
!!!! 1 | Differences from the Arduino Uno
Changed lines 11-12 from:
'''Single processor for sketches and USB communication.'''
to:
1 | '''Single processor for sketches and USB communication.'''
April 24, 2012, at 04:08 PM by Scott Fitzgerald -
Changed lines 5-6 from:
!!!!Differences from the Arduino Uno
to:
(:*toc:)

!!!! 2 | Differences from the Arduino Uno
Changed lines 45-46 from:
!!!Installing Drivers for the Leonardo
to:
!!! 2 | Installing Drivers for the Leonardo
Changed lines 71-72 from:
!!!Uploading Code to the Leonardo
to:
!!! 3 | Uploading Code to the Leonardo
Changed lines 79-80 from:
!!!Good Coding Practice With the Leonardo
to:
!!! 4 | Good Coding Practice With the Leonardo
April 11, 2012, at 05:55 PM by Scott Fitzgerald -
Changed lines 50-51 from:
'''Windows (tested on XP and 7)'''
*Plug in your board and wait for Windows to begin its driver installation process.
to:
'''Windows (tested on XP and 7)'''\\
The process for Windows XP and Windows 7 is similar. These screenshots are from an XP installation. \\

*Plug in your board and wait for Windows to begin its driver installation process. If the installer does not launch automatically, Navigate to the Windows Device Manager (Start>Control Panel>Hardware) and find the Arduino Leonardo listing. Right click and choose '''Update driver'''.
April 11, 2012, at 05:50 PM by Scott Fitzgerald -
Changed line 63 from:
'''Linux'''
to:
'''Linux'''\\
Added lines 65-66:

April 11, 2012, at 05:48 PM by Scott Fitzgerald -
Changed lines 50-65 from:
'''Windows 7'''
*Plug in your board and wait for Windows to begin its driver installation process. After a few moments, the process will fail, despite its best efforts
*Click on the Start Menu, and open up the Control Panel.
*While in the Control Panel, navigate to System and Security. Next, click on System. Once the System window is up, open the Device Manager.
*In the Device Manager, look for the item "Other devices". You should see an item below that name "Arduino Leonardo" with a yellow exclamation mark next to it.
Attach:Win7LeoDriverDeviceManager.png
*Right click on "Arduino Leonardo" and choose the "Update Driver Software" option.
*Next, choose the "Let me pick from a list of device drivers on my computer" option.
Attach:Win7LeoDriverBrowseDriver.png
*Choose "HID-compliant device" under the "(Standard System devices)" category. Click on the "Have Disk" button.
Attach:Win7LeoDriverChooseDevice.png
*When asked for the disk location, navigate to the folder containing the Leonardo's driver file, named "Leonardo.inf", located in the "Drivers" folder of the Arduino Software download.
*You will receive a warning about Windows being unable to verify the software publisher. Click the "install this driver anyway" option.
*Windows will finish up the driver installation. You can verify it is finished by checking your Device Manager again. The Leonardo should be assigned a COM port.
Attach:Win7LeoDriverFinishedDevMgr.png
to:
'''Windows (tested on XP and 7)'''
*Plug in your board and wait for Windows to begin its driver installation process.
*If prompted to search for drivers online, choose "No, not this time". And click '''Next'''
Attach:LeonardoWindowsDrivers1.png
*When asked to install automatically or from a specific location, select "Install from a list or specific location" and press '''Next'''
Attach:LeonardoWindowsDrivers2.png
*Choose "Search for the best driver in these locations", and check the box "incude this location in the search". Click the '''Browse''' button and navigate to your Arduino 1.0.1 or later installation. Select the '''drivers''' folder an click '''OK'''
Attach:LeonardoWindowsDrivers3.png
*Click '''Next'''
*You will receive a notification that the Leonardo has not passed Windows Logo testing. Click on the button '''Continue Anyway'''
Attach:LeonardoWindowsDrivers5.png
*After a few moments, a window will tell you the wizard has finished installing software for Arduino Leonardo. Press the '''Finish''' button
Changed line 64 from:
to:
There is no need to install drivers for Ubuntu 10.0.4
April 09, 2012, at 06:43 PM by Tom Igoe -
Changed lines 74-75 from:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated when the computer opens the Leonardo's serial port at 1200 baud and then closes it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)
to:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated when the computer opens the Leonardo's serial port at 1200 baud and then closes it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)
Changed lines 80-100 from:
to:
'''Using the serial monitor effectively''': Since serial is going through only one processor on the Leonardo, the board is capable of filling your computer's serial buffer faster than the Uno or earlier boards. You may notice that if you send serial continually, for example like this:

(:source lang=arduino :)
void loop() {
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
}
(:sourceend:)

the Serial Monitor in the IDE slows down considerably as it tries to keep up. If you encounter this, add a short delay to your loop so that the computer's serial buffer is not filled as fast. Even a millisecond delay will help:

(:source lang=arduino :)
void loop() {
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
delay(1);
}
(:sourceend:)

Serial applications using native libraries other than RXTX library read the serial buffer faster, so you may not encounter this error much outside of the Serial Monitor, Processing, or other RXTX-based serial applications
April 09, 2012, at 05:06 PM by Tom Igoe -
Changed lines 15-16 from:
The use of a single chip means every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.
to:
Since the Leonardo does not have a dedicated chip to handle serial communication, it means that the serial port is '''virtual''' -- it's a software routine, both on your operating system, and on the Leonardo itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the Leonardo creates a serial instance whenever it runs its bootloader. The Leonardo is an instance of USB's '''Connected Device Class (CDC)''' driver.

This means that every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.
Changed lines 21-22 from:
Unlike the Arduino Uno, the Leonardo doesn't reset when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.
to:
Unlike the Arduino Uno, the Leonardo doesn't restart your sketch when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.
Changed lines 33-34 from:
One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See the "Good Coding Practice" section below for a warning about using this functionality.
to:
One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual serial port to your operating system (also called CDC) for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See the "Good Coding Practice" section below for a warning about using this functionality.
Changed lines 37-38 from:
On the Leonardo, the main '''Serial''' class refers to this keyboard and mouse emulation over USB. To use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
to:
On the Leonardo, the main '''Serial''' class refers to the virtual serial driver on the Leonardo for connection to your computer over USB. It's not connected to the physical pins 0 and 1 as it is on the Uno and earlier boards. To use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
Added line 47:
Changed lines 72-73 from:
However, because the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
to:
However, because the Leonardo's serial port is virtual, it disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
April 09, 2012, at 04:56 PM by Tom Igoe -
Changed lines 67-68 from:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch.
to:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Click the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch.
April 09, 2012, at 04:55 PM by Tom Igoe -
Changed line 44 from:
*The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. There's nothing to configure with the Leonardo, so you can close this dialoge by clicking the red button in the top left of the window.
to:
*The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. There's nothing to configure with the Leonardo, so you can close this dialogue by clicking the red button in the top left of the window.
April 02, 2012, at 03:15 PM by Tom Igoe -
Added lines 21-28:
This change means that if you're using any Serial print(), println() or write() statments in your setup, they won't show up when you open the serial monitor. To work around this, you can check to see if the serial port is open like so:

(:source lang=arduino tab=4 :)
// while the serial stream is not open, do nothing:
while (!Serial) ;
(:sourceend:)

March 31, 2012, at 12:46 AM by Scott Fitzgerald -
Changed lines 36-38 from:
to:
*The first time you plug a Leonardo into a Mac, the "Keyboard Setup Assistant" will launch. There's nothing to configure with the Leonardo, so you can close this dialoge by clicking the red button in the top left of the window.
Attach:OSXKeyboardNotification.png
March 31, 2012, at 12:23 AM by Scott Fitzgerald -
Changed line 49 from:
*You will receive a warning about Windows being unable to verify the software publisher. Click the "install this river anyway" option.
to:
*You will receive a warning about Windows being unable to verify the software publisher. Click the "install this driver anyway" option.
March 31, 2012, at 12:22 AM by Scott Fitzgerald -
March 31, 2012, at 12:22 AM by Scott Fitzgerald -
March 31, 2012, at 12:21 AM by Scott Fitzgerald -
Changed line 42 from:
Attach: Win7LeoDriverDeviceManager.png
to:
Attach:Win7LeoDriverDeviceManager.png
March 27, 2012, at 09:27 PM by Scott Fitzgerald -
March 27, 2012, at 09:27 PM by Scott Fitzgerald -
Added line 42:
Attach: Win7LeoDriverDeviceManager.png
Added line 45:
Attach:Win7LeoDriverBrowseDriver.png
Added line 47:
Attach:Win7LeoDriverChooseDevice.png
Changed lines 51-52 from:
to:
Attach:Win7LeoDriverFinishedDevMgr.png
March 27, 2012, at 09:24 PM by Scott Fitzgerald - added Win7 installation
Changed lines 38-48 from:
to:
*Plug in your board and wait for Windows to begin its driver installation process. After a few moments, the process will fail, despite its best efforts
*Click on the Start Menu, and open up the Control Panel.
*While in the Control Panel, navigate to System and Security. Next, click on System. Once the System window is up, open the Device Manager.
*In the Device Manager, look for the item "Other devices". You should see an item below that name "Arduino Leonardo" with a yellow exclamation mark next to it.
*Right click on "Arduino Leonardo" and choose the "Update Driver Software" option.
*Next, choose the "Let me pick from a list of device drivers on my computer" option.
*Choose "HID-compliant device" under the "(Standard System devices)" category. Click on the "Have Disk" button.
*When asked for the disk location, navigate to the folder containing the Leonardo's driver file, named "Leonardo.inf", located in the "Drivers" folder of the Arduino Software download.
*You will receive a warning about Windows being unable to verify the software publisher. Click the "install this river anyway" option.
*Windows will finish up the driver installation. You can verify it is finished by checking your Device Manager again. The Leonardo should be assigned a COM port.
March 27, 2012, at 07:04 PM by Scott Fitzgerald -
Changed lines 11-12 from:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains established regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.
to:
The Leonardo differs from previous Arduino boards in that it uses a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains established regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.
Changed lines 23-24 from:
One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See below for a warning about using this functionality.
to:
One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See the "Good Coding Practice" section below for a warning about using this functionality.
Changed lines 27-28 from:
On the Leonardo, the main '''Serial''' class refers to this USB communication with the computer; to use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
to:
On the Leonardo, the main '''Serial''' class refers to this keyboard and mouse emulation over USB. To use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
Added lines 35-40:
'''OSX'''

'''Windows 7'''

'''Linux'''
Changed lines 45-46 from:
Because, however, the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
to:
However, because the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
Changed line 56 from:
\\
to:
\\
March 25, 2012, at 09:11 PM by David A. Mellis -
Changed lines 37-38 from:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch. Because, however, the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
to:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch.

Because, however, the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.
March 25, 2012, at 09:10 PM by David A. Mellis -
Changed lines 31-32 from:
The Leonardo has some slight differences in the capabilities and assignments of various pins, these are detailed on the [[Main/ArduinoBoardLeonardo | hardware page]].
to:
The Leonardo has some slight differences in the capabilities and assignments of various pins (especially for SPI and TWI). These are detailed on the [[Main/ArduinoBoardLeonardo | hardware page]].
March 25, 2012, at 09:08 PM by David A. Mellis -
Added lines 29-32:
'''Differences in pin capabilities.'''

The Leonardo has some slight differences in the capabilities and assignments of various pins, these are detailed on the [[Main/ArduinoBoardLeonardo | hardware page]].
March 25, 2012, at 09:04 PM by David A. Mellis -
Changed lines 3-4 from:
In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences. To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. The Leonardo does not contain a secondary processor dedicated to USB communication. This changes some details about the upload process and the serial class. It also allows the Leonardo to support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes for emulating those devices.
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.
Added lines 7-8:
In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences.
Added lines 17-20:
'''No reset when you open the serial port.'''

Unlike the Arduino Uno, the Leonardo doesn't reset when you open its serial port on the computer. That means you won't see serial data that's already been sent to the computer by the board, including, for example, most data sent in the setup() function.
Changed lines 23-24 from:
One advantage of using a single chip, though, is that while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse.
to:
One advantage of using a single chip for your sketches and for USB is increased flexibility in the communication with the computer. While the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. See below for a warning about using this functionality.
March 25, 2012, at 08:55 PM by David A. Mellis -
Changed lines 3-6 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences. The Leonardo does not contain a secondary processor dedicated to USB communication. This changes some details about the upload process and the serial class. It also allows the Leonardo to support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes for emulating those devices.

!!!!Communication with the Computer
to:
In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences. To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. The Leonardo does not contain a secondary processor dedicated to USB communication. This changes some details about the upload process and the serial class. It also allows the Leonardo to support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes for emulating those devices.

!!!!Differences from the Arduino Uno

'''Single processor for sketches and USB communication.'''
March 25, 2012, at 08:52 PM by David A. Mellis -
Changed lines 3-4 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program the Leonardo as you would other Arduino boards. The Leonardo supports the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes, allowing it to emulate those devices.
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program and use the Leonardo as you would other Arduino boards. There are, however, a few important differences. The Leonardo does not contain a secondary processor dedicated to USB communication. This changes some details about the upload process and the serial class. It also allows the Leonardo to support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes for emulating those devices.
Changed lines 7-10 from:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.

In particular, while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. However, every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.
to:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains established regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.

'''Serial re-enumeration on reset.'''

The use of a single chip means every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.

'''Keyboard and mouse emulation.'''

One advantage of using a single chip, though, is that while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse.

'''Separation of USB and serial communication.'''
March 17, 2012, at 08:00 PM by David A. Mellis -
Changed lines 7-8 from:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor. On the Leonardo, the main '''Serial''' class refers to this USB communication with the computer; to use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
to:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.
Added lines 11-12:
On the Leonardo, the main '''Serial''' class refers to this USB communication with the computer; to use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
March 17, 2012, at 08:00 PM by David A. Mellis -
Changed lines 7-8 from:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.
to:
The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor. On the Leonardo, the main '''Serial''' class refers to this USB communication with the computer; to use the hardware serial port (pins 0 and 1, RX and TX), use '''Serial1'''. (See the [[/Reference/Serial | Serial reference pages]] for more information.)
Changed lines 23-24 from:
The Leonardo's main serial port is not tied to pins 0 and 1 as on the Uno. If you wish to use the TX and RX pins for serial communication, use Serial1. See the [[/Reference/Serial | Serial reference pages]] for more information. This is a second hardware serial port specific to the Leonardo.
to:
March 17, 2012, at 07:57 PM by David A. Mellis -
Changed lines 5-6 from:
!!!!USB Communication
to:
!!!!Communication with the Computer
March 17, 2012, at 07:56 PM by David A. Mellis -
Changed lines 3-4 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program the Leonardo as you would other Arduino boards. The Leonardo support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes, allowing it to emulate those devices.
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program the Leonardo as you would other Arduino boards. The Leonardo supports the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes, allowing it to emulate those devices.

!!!!USB Communication
March 17, 2012, at 07:46 PM by David A. Mellis -
Changed lines 15-16 from:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated by opening the Leonardo's serial port at 1200 baud and then closing it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)
to:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated when the computer opens the Leonardo's serial port at 1200 baud and then closes it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)
March 17, 2012, at 07:44 PM by David A. Mellis -
Changed lines 15-16 from:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work.
to:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work. (Note that the auto-reset is initiated by opening the Leonardo's serial port at 1200 baud and then closing it; this won't work if something interferes with the board's USB communication - e.g. disabling interrupts.)
March 17, 2012, at 07:42 PM by David A. Mellis -
Changed lines 15-16 from:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it.
to:
These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it. Again, this is only necessary if the normal upload process (i.e. just pressing the uploading button) doesn't work.
March 17, 2012, at 07:40 PM by David A. Mellis -
Changed lines 3-4 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE. In general, you program the Leonardo as you would other Arduino boards. The Leonardo support the [[Reference/MouseKeyboard | Keyboard and Mouse]] classes, allowing it to emulate those devices.
Changed lines 7-8 from:
In particular, while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. Additionally, every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.
to:
In particular, while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. However, every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.
Changed lines 13-18 from:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader, which is responsible for receiving, storing, and starting the new sketch.

The big difference between the Leonardo and previous models is that the USB connection is in the bootloader. This means changes for the way you work with the board.

This will happen every time you upload a new sketch. The IDE will close the serial monitor properly when you click '''Upload''', but you should make sure all serial connections are closed before you you reset using the hardware reset button.
to:
In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and then started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader - which is responsible for receiving, storing, and starting the new sketch. Because, however, the Leonardo's virtual (CDC) serial / COM port disappears when the boards resets, the Arduino software uses a different strategy for timing the upload than with the Uno and other boards. In particular, after initiating the auto-reset of the Leonardo (using the serial port selected in the '''Tools > Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the Leonardo bootloader. It then performs the upload on this newly-appeared port.

These differences affect the way you use the physical reset button to perform an upload if the auto-reset isn't working. Press and hold the reset button on the Leonardo, ''then'' hit the upload button in the Arduino software. Only release the reset button after you see the message "Uploading..." appear in the software's status bar. When you do so, the bootloader will start, creating a new virtual (CDC) serial / COM port on the computer. The software will see that port appear and perform the upload using it.
March 17, 2012, at 06:55 PM by David A. Mellis -
Changed lines 3-8 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. Once connected, it will be recognized as a HID compliant device. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.

The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer.

!!!Good Coding Practice With the Leonardo
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.

The Leonardo differs from previous Arduino boards in using a single microcontroller to both run your sketches and for USB communication with the computer. The Uno and other boards use separate microcontrollers for these two functions, meaning that the USB connection to the computer remains constant regardless of the state of the main microcontroller. By combining these two functions onto a single processor, the Leonardo allows for more flexibility in its communication with the computer. It also helps to lower the cost of the board by removing the need for an additional processor.

In particular, while the Leonardo appears as a virtual (CDC) serial (COM) port for programming and communication (as with the Arduino Uno), it can also behave as a (HID) keyboard or mouse. Additionally, every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This is in contrast to the Arduino Uno, with which you can reset the main processor (the ATmega328P) without closing the USB connection (which is maintained by the secondary ATmega8U2 or ATmega16U2 processor). This difference has implications for driver installation, uploading, and communication; these are discussed below.

!!!Installing Drivers for the Leonardo

!!!Uploading Code to the Leonardo

In general, you upload code to the Leonardo as you would with the Uno or other Arduino boards. Press the upload button in the Arduino software and your sketch will be automatically uploaded onto the Leonardo and started. This works more or less the same way as with the Uno: the Arduino software initiates a reset of the Leonardo, launching the bootloader, which is responsible for receiving, storing, and starting the new sketch.
Changed lines 17-19 from:
Every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This will happen every time you upload a new sketch. The IDE will close the serial monitor properly when you click '''Upload''', but you should make sure all serial connections are closed before you you reset using the hardware reset button.

to:
This will happen every time you upload a new sketch. The IDE will close the serial monitor properly when you click '''Upload''', but you should make sure all serial connections are closed before you you reset using the hardware reset button.

!!!Good Coding Practice With the Leonardo
December 23, 2011, at 03:14 PM by Tom Igoe -
Added lines 7-13:
!!!Good Coding Practice With the Leonardo

The big difference between the Leonardo and previous models is that the USB connection is in the bootloader. This means changes for the way you work with the board.

Every time you reset the board, the Leonardo's USB serial connection will be broken and re-established. The Leonardo will disappear from the list of serial ports, and the list will re-enumerate. Any program that has an open serial connection to the Leonardo will lose its connection. This will happen every time you upload a new sketch. The IDE will close the serial monitor properly when you click '''Upload''', but you should make sure all serial connections are closed before you you reset using the hardware reset button.

December 12, 2011, at 05:38 PM by Scott Fitzgerald -
December 12, 2011, at 05:32 PM by Scott Fitzgerald -
Changed line 13 from:
to:
\\
December 12, 2011, at 05:32 PM by Scott Fitzgerald -
Added lines 12-13:
\\
December 09, 2011, at 03:50 AM by Scott Fitzgerald -
Changed lines 7-8 from:
'''A word of caution on using the Leonardo as a Mouse or Keyboard''': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.
to:
'''A word of caution on using the Leonardo as a Mouse or Keyboard''': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system to turn this functionality on, like a physical switch or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.
December 09, 2011, at 03:49 AM by Scott Fitzgerald -
Changed lines 7-8 from:
''A word of caution on using the Leonardo as a Mouse or Keyboard'': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.
to:
'''A word of caution on using the Leonardo as a Mouse or Keyboard''': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.
December 09, 2011, at 03:49 AM by Scott Fitzgerald -
Changed lines 7-10 from:
A word of caution on using the Leonardo as a Mouse or Keyboard: if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.

Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. Refer to the Mouse and Keyboard examples for some ways to handle this.
to:
''A word of caution on using the Leonardo as a Mouse or Keyboard'': if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported. Refer to the Mouse and Keyboard examples for some ways to handle this.
December 09, 2011, at 03:45 AM by Scott Fitzgerald -
Changed lines 5-8 from:
The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer. Special care must be taken when the board is plugged into your computer. It can take over your machine, making it difficult, if not impossible to program.

It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.
to:
The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer.

A word of caution on using the Leonardo as a Mouse or Keyboard: if the Mouse or Keyboard library is constantly running, it will be difficult to program your board. It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.
December 07, 2011, at 08:39 PM by Scott Fitzgerald -
Added lines 7-8:
It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.
Deleted lines 10-13:
It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.

When using either the Mouse or the Keyboard functionality with a Leonardo, it is strongly recommended you set up a control system that allows you to enable and disable the commands. A toggle or pushbutton works well.
December 07, 2011, at 08:38 PM by Scott Fitzgerald -
Deleted line 2:
Changed lines 5-6 from:
The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer. Special care must be taken when the board is plugged into your computer. It will take over your machine, making it difficult, if not impossible to program.
to:
The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer. Special care must be taken when the board is plugged into your computer. It can take over your machine, making it difficult, if not impossible to program.

Functions such as Mouse.move() and Keyboard.print() will move your cursor or send keystrokes to a connected computer and should only be called when you are ready to handle them. It is recommended to use a control system, like a physical switch to turn this functionality on, or only responding to specific input you can control. Refer to the Mouse and Keyboard examples for some ways to handle this.
December 07, 2011, at 07:51 PM by Scott Fitzgerald -
Deleted lines 5-6:
The Leonardo's main serial port is not tied to pins 0 and 1 as on the Uno. If you wish to use the TX and RX pins for serial communication, use Serial1 as you would with the Mega2560. This is a second hardware serial port specific to the Leonardo.
Added lines 12-13:
The Leonardo's main serial port is not tied to pins 0 and 1 as on the Uno. If you wish to use the TX and RX pins for serial communication, use Serial1. See the [[/Reference/Serial | Serial reference pages]] for more information. This is a second hardware serial port specific to the Leonardo.
December 07, 2011, at 07:42 PM by Scott Fitzgerald -
Changed lines 6-7 from:
The Leonardo, because of its onboard USB drivers, will appear as a native mouse or keyboard to a host computer. Because of this, special care must be taken when the board is plugged into your computer. It will take over your machine, making it difficult, if not impossible to program.
to:
The Leonardo's main serial port is not tied to pins 0 and 1 as on the Uno. If you wish to use the TX and RX pins for serial communication, use Serial1 as you would with the Mega2560. This is a second hardware serial port specific to the Leonardo.

The Leonardo will appear on a virtual serial port or COM device similar to the Arduino Uno for programming and communication purposes, but also can appear as a native mouse or keyboard to a host computer. Special care must be taken when the board is plugged into your computer. It will take over your machine, making it difficult, if not impossible to program.
December 07, 2011, at 06:34 PM by Scott Fitzgerald -
Changed lines 4-9 from:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board.

When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.


For more details on the Arduino Leonardo, see the [[Main/ArduinoBoardLeonardo | hardware page]].
to:
To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board. Once connected, it will be recognized as a HID compliant device. When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.

The Leonardo, because of its onboard USB drivers, will appear as a native mouse or keyboard to a host computer. Because of this, special care must be taken when the board is plugged into your computer. It will take over your machine, making it difficult, if not impossible to program.

It is very important to make sure you have control of your computer when the Leonardo is connected. When using the Mouse or Keyboard library, it may be best to test your output first using Serial.print(). This way, you can be sure you know what values are being reported.

When using either the Mouse or the Keyboard functionality with a Leonardo, it is strongly recommended you set up a control system that allows you to enable and disable the commands. A toggle or pushbutton works well.

For more details on the Arduino Leonardo, see the [[Main/ArduinoBoardLeonardo | hardware page]] and the [[Reference/MouseKeyboard | Mouse and Keyboard reference pages]].
December 07, 2011, at 05:56 PM by Scott Fitzgerald -
Added lines 1-9:
!!Guide to the Arduino Leonardo


To connect the Arduino Leonardo to your computer, you'll need a Micro-B USB cable. This USB cable provides power and data to the board.

When programming the Leonardo, you must choose '''Arduino Leonardo''' from the '''Tools > Board''' menu in the Arduino IDE.


For more details on the Arduino Leonardo, see the [[Main/ArduinoBoardLeonardo | hardware page]].

Share