Guide.ArduinoLeonardoMicro History

Hide minor edits - Show changes to output

November 04, 2013, at 08:22 AM by Scott Fitzgerald -
Changed lines 23-26 from:
Unlike the Arduino Uno, the Leonardo and Micro won't restart your sketch when you open a 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 like so:
to:
Unlike the Arduino Uno, the Leonardo and Micro won't restart your sketch when you open a 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()@@ like so:
Added line 28:
Serial.begin(9600);
September 30, 2013, at 08:54 PM by Roberto Guido - todo's corrections
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 and Micro'''

!!! OSX
to:
!!! Installing Drivers for the Leonardo and Micro

!!!! OSX
Changed lines 52-53 from:
!!!! Instructions for Windows
to:
!!! Instructions for Windows
Changed lines 74-75 from:
!!! Linux\\
to:
!!!! Linux\\
Changed lines 79-80 from:
!!!! '''Uploading Code to the Leonardo and Micro'''
to:
!!! Uploading Code to the Leonardo and Micro
Changed lines 87-88 from:
!!!! '''Good Coding Practice With the Leonardo and Micro'''
to:
!!! Good Coding Practice With the Leonardo and Micro
December 19, 2012, at 04:21 PM by Alessandro Argenio -
December 19, 2012, at 04:20 PM by Alessandro Argenio -
December 18, 2012, at 06:22 PM by Alessandro Argenio -
December 17, 2012, at 06:02 PM by Alessandro Argenio -
Changed line 56 from:
* 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 Esplora listing. Right click and choose '''Update driver'''.[[<<]]
to:
* 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'''.[[<<]]
Changed lines 72-73 from:
* After a few moments, a window will tell you the wizard has finished installing software for Arduino Esplora. Press the '''Close''' button.
to:
* After a few moments, a window will tell you the wizard has finished installing software for Arduino Leonardo. Press the '''Close''' button.
December 17, 2012, at 05:52 PM by Alessandro Argenio -
Changed lines 62-63 from:
Attach:EsploraWindowsDrivers1.png
to:
Attach:LeonardoWindowsDrivers1.png
December 17, 2012, at 05:07 PM by Alessandro Argenio -
Changed lines 58-59 from:
Attach:EsploraWindowsDrivers0.png
to:
Attach:LeonardoWindowsDrivers0.png
Changed lines 66-67 from:
Attach:EsploraWindowsDrivers2.png
to:
Attach:LeonardoWindowsDrivers2.png
Changed lines 70-71 from:
Attach:EsploraWindowsDrivers3.png
to:
Attach:LeonardoWindowsDrivers3.png
December 17, 2012, at 04:45 PM by Alessandro Argenio -
Changed lines 52-67 from:
!!! 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 or Arduino Micro 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 "include 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 board 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 or Arduino Micro. Press the '''Finish''' button
to:
!!!! Instructions for Windows

The following instructions are for Windows 7. They are valid also for Windows XP, with small differences in the dialog windows.

* 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 Esplora listing. Right click and choose '''Update driver'''.[[<<]]

Attach:EsploraWindowsDrivers0.png

* At the next screen, choose "Browse my computer for driver software", and click '''Next'''.

Attach:EsploraWindowsDrivers1.png

* Click the '''Browse...''' button. Another dialog appears: navigate to the folder with the Arduino software that you just downloaded. Select the '''drivers''' folder an click '''OK''', then click '''Next'''.

Attach:EsploraWindowsDrivers2.png

* You will receive a notification that the board has not passed Windows Logo testing. Click on the button '''Continue Anyway'''.

Attach:EsploraWindowsDrivers3.png

* After a few moments, a window will tell you the wizard has finished installing software for Arduino Esplora. Press the '''Close''' button.
December 17, 2012, at 04:40 PM by Alessandro Argenio -
Changed line 61 from:
*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'''
to:
*Choose "Search for the best driver in these locations", and check the box "include 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'''
November 02, 2012, at 02:18 PM by Scott Fitzgerald -
Changed lines 3-4 from:
To connect the Arduino Leonardo or Micro 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 or Micro''' from the '''Tools > Board''' menu in the Arduino IDE.
to:
To connect the Arduino Leonardo or Micro 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" or "Arduino Micro''' from the '''Tools > Board''' menu in the Arduino IDE.
October 31, 2012, at 08:55 PM by Scott Fitzgerald - Page creation
Added lines 1-108:
!!Guide to the Arduino Leonardo and Micro

To connect the Arduino Leonardo or Micro 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 or Micro''' from the '''Tools > Board''' menu in the Arduino IDE.

(:*toc:)

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

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

!!! Single processor for sketches and USB communication.

The Leonardo and Micro differ from other Arduino boards in that they use 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 boards do 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 board itself. Just as your computer creates an instance of the serial port driver when you plug in any Arduino, the Leonardo/Micro creates a serial instance whenever it runs its bootloader. The board is an instance of USB's '''Connected Device Class (CDC)''' driver.

This means that every time you reset the board, the USB serial connection will be broken and re-established. The board 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 and Micro won't restart your sketch when you open a 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 like so:

(:source lang=arduino tab=4 :)
// 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 board 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 and Micro, the main '''Serial''' class refers to the virtual serial driver on the board 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 and Micro'''

!!! OSX
*The first time you plug a Leonardo or Micro 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 or Arduino Micro 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 board 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 or Arduino Micro. Press the '''Finish''' button

!!! Linux\\

There is no need to install drivers for Ubuntu 10.0.4


!!!! '''Uploading Code to the Leonardo and Micro'''

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

However, because the serial port is virtual, it disappears when the board 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 or Micro (using the serial port selected in the '''Tools &gt; Serial Port''' menu), the Arduino software waits for a new virtual (CDC) serial / COM port to appear - one that it assumes represents the 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 or Micro, ''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 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 and Micro'''

'''A word of caution on using the USB Mouse and Keyboard Libraries''': 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, 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 and Micro, see the [[Main/ArduinoBoardLeonardo | Leonardo hardware page]] and [[Main/ArduinoBoardMicro | Micro hardware page]]. For additional information on the USB capabilities, see the [[Reference/MouseKeyboard | Mouse and Keyboard reference pages]].
\\
\\

Share