Home  ›  Getting Started  ›  Arduino  ›  Getting Started with Arduino Leonardo

Tags: , ,

Getting Started with Arduino Leonardo


Good! You are here because you wanted to use Arduino. 1st thing 1st, you will need the necessary tools to get started.

Introduction

Arduino Leonardo is the addition to the Arduino family with added feature and new functionalities. The microcontroller used on this board is ATmega32u4 instead of ATmega328 on older version boards such as Arduino Uno. This board is equipped with more digital pins, PWM pins and analog pins. The ATmega32u4 has built-in USB communication which eliminates the need for a secondary processor to handle USB communication.

But for beginner, it is still advisable to use earlier version boards such as Arduino Uno as some of the pins are different and some shields may not be compatible. Other than that, the on board microcontroller now comes soldered as it is a surface mount device as oppose to the previous boards where the microcontroller could be unplug and replaced easily if it is burnt (this is very normal for beginners!). The USB connection may be confusing for the beginners. Every time you reset the board, the Leonardo’s USB serial connection will be broken and re-established which may have implications for driver installation, uploading, and communication.

Arduino Main Board


Currently, there are > 10 types of Arduino main board in the market including 3rd party, compatible version, etc. We will be talking about Arduino Leonardo in this tutorial . You can also refer to :

USB cable

USB cable is used to connect Arduino Main Board to the computer/laptop for loading program, for power and also for serial communication. Arduino Leonardo uses USB Micro B Cable. The board does not come with the cable, so you will have to get one! BTW, USB micro B type cable is commonly used on smartphones and newer USB devices, if you have one, just use it temporary.


Arduino IDE

Arduino IDE is the software tool needed to write sketch (code), and load into the Arduino main board. Please go to Arduino website at arduino.cc, under Download, please download the corresponding IDE base on your Operating system (Windows, Mac OS X, Linux). This is the location to download the latest version of Arduino IDE.


Unzip the downloaded file.

Arduino Main Board to Computer

Now, since this is your 1st time, it is always going to be painful, right? BTW, I will be showing the steps using Windows XP only  Connect the micro B type end of USB cable to Arduino Leonardo, and the other end to the computer/laptop USB port. Arduino Leonardo will automatically use the power from USB to start up. The green LED (ON) on Arduino Leonardo should be ON and Red LED (L) will. 1st time user, you will need to install the USB driver for communication. You should also hear sound from the computer and a little popup message box at the bottom right corner of the screen saying Found New Hardware…..Arduino Leonardo …. you will need to install the driver 


The Found New Hardware Wizard will appear and please select No, not this time and click Next >. If it does not appear, go to the Windows Device Manager (Start>Control Panel>Hardware) and find the Arduino Leonardo listing. Right click and choose Update driver.


Select Install from a list of specific location (Advanced) in the next screen. Click Next >


The next screen, make sure you select Include this location and browse to the Arduino IDE folder that you just downloaded and upzipped. Select the drivers folder, and click OKDO NOT go inside FDTI USB Drivers folder, that is for Arduino Duemilanove and older version.


The wizard should start searching for necessary files and install the driver, you might get this warning message pop up, just click Continue Anyway.Once completed, click Finish.


You might need to reboot/restart the computer to get the driver working properly, don’t worry, it’s only a one time work! After the computer reboot, please make sure the Arduino is plugged to the computer through the USB cable. where the green LED is ON. We would like to know which COM number is the Arduino Leonardo connected to. Go to the Device Manager (from the Start Menu, select Settings -> Control Panel. Double Click on System and select Hardware tab. Then click onDevice Manager).


Look for an entry under Ports (COM & LPT) that shows USB Serial Port (COM”X”) where  X is a decimal number from 1 to 100. Seriously, I have seen COM72 before! Anyway the X can be any number and it should be a unique number and we need it in Arduino IDE later. So in this case, the COM number is 15. You will need to select the correct COM number to load program/sketch into Arduino Leonardo later. If you don’t see any USB Serial Port, unplug USB cable and plug in again. Good the pain is over  Let’s move to the fun part. 

Hello World in Arduino – LED blinking 

Open the folder Arduino that you download and unzipped, you should see a file named arduino.exe, double click it, Arduino IDE will appear, it may take a while to load, ~ 10 seconds.


This is the Arduino IDE:


Make sure the Arduino Leonardo is connected to computer with the USB cable. Arduino IDE support many Arduino main board, including Leonardo  We will need to select the correct board and microcontroller. Goto Tools -> Board -> Arduino Leonardo, click it.


Now, make sure Arduino IDE knows which COM Port the Arduino Leonardo is connected to. Goto Tools -> Serial Port -> COM?, it depends on the COM number you checked from the device manager, make sure you select the same COM number. Remember, the number might be different when you use different USB port, change different Arduino board and different computer. Again, mine is COM15. Do not follow my COM number, choose yours.


The settings will appear at the bottom right corner of Arduino IDE.


Now, you are ready to load the 1st example code, Blinking  Goto File -> Examples -> Basic -> Blink, click it. The example sketch/program will appear in a new Arduino IDE window, don’t worry, it’s perfectly normal. You can ignore the empty Arduino IDE that appeared earlier. You can close it or leave it. We will work on the new Arduino IDE with Blink sketch.


You can click the upload icon, Arduino IDE will compile the sketch and upload into Arduino Leonardo connected to your computer (if there is no error), further run the sketch on Arduino Leonardo. You will just have to wait until the message box say Upload Done and look at the Arduino Leonardo. The red LED will Blink at 1 second rate.


We can now make the changes. Scroll down the program/sketch, in the loop function. Modify the value from delay(1000) to delay(100), for both the delay. Click on the Uploadicon and sit back, wait until it is done uploading.


Now, look at the Red LED blinking rate, it has become faster  You have successfully load an example code/sketch and modify it. Hurray! You can try the other examples, but most will require additional shields or components. We will come out with more tutorials, stay tuned! We have another version of Arduino tutorial here.


7 Responses to “Getting Started with Arduino Leonardo”

  1. khaled.terzaki says:

    Dear Phang,
    I followed all your instructions and still wont work. I monitored the leonardo board and found that an orange led blinks continuously and each time i upload the blinking program it rests itself and a new hardware massage appears. What should I do?.

    sincerely,

    khaled.terzaki

  2. woyongguoxin says:

    I met the same question.Now I solved it.You just power on the Arduino Leonardo board with 7-12 input voltage.It will be ok.

  3. programmer says:

    hello
    thanx for this information but i have a question about the other usb in leonardo if there is another usb in leonardo (D0,D1) how i can connect or upload the sketch to it , if the attached usb connect to the baord of leonardo by cable and choose the port by the way you show above, my question is the other usb in leonardo how can reach from labtop.
    thank you.

  4. TheNoob says:

    Hello, I’m a beginner and wanted to know how to set up a breadboard to run this program as I have one but have no idea how to set it up, please can you help :)

  5. ober says:

    If you want to setup on breadboard, I would recommend using Arduino UNO instead of Leonardo. If you have further inquiry, please do post in our technical forum, thanks.

  6. ober says:

    D1 and D0 is not USB, is UART. Is another type of Serial communication. Leonardo does not use UART to upload program, older Arduino uses that, example Duemilanove, UNO, Mega uses UART to load program.

  7. Hello,I have a Leonardo and a Mack. Finally I got a U-tube video Tutorial. I ran into a problem choosing the USB Serial and don’t know which to use.That Video has different USB’s than mine. I did upload the Blinking sketch but error showed regarding that USB connection. 99% of the tutorials are Windows inclined. Total frustration friends .Any suggestion please let me know. Thanks….

Leave a Reply

Help us improve the wiki Send Your Comments