Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

Using the Arduino IDE

This part of Arduino beginners course shows you how to install and use the Arduino IDE for uploading a simple sketch to the Arduino Uno. It shows in detail screen shots of each part of the process so you can follow along. All you need for this part of the course is an Arduino Uno and a USB cable.


The IDE gives you a very simple interface which is one of the reasons the Arduino is so popular. It gives you a simple editor and virtually one button programming of the Arduino. Here's the IDE when you first start it.

Arduino IDE first start

The black area at the bottom is where programming status will be displayed and the top white are is where you enter your programs to control the Arduino. Bottom right shows you the board currently selected.

Ardino IDE - Board selection

The Arduino IDE can progarm many different types of boards such as the Uno, Mega, Leonard and many more. To set up the IDE for your board use the Menu:

Menu > Tools > Board:

Now select: "Arduino/Genuino Uno"

arduno IDE Board selection
The new board selection will be displayed in the arduino IDE at the bottom right.

Arduino Uno to PC link setup

Serial Port Selection

The Arduino Uno communicates to yor PC via a serial USB link using an RS232 port.  You now need to select the port in use by the Arduino.

Plug in the USB cable from your PC to the Arduino. 

Now use the Menu:

Menu > Tools > Port

You will see text showing you to which port the Arduno is attached - Select it.

Arduino IDE port Selection

Note: Your port number may be different e.g. COM5. Select whichever has the "Arduino/Genuion Uno" text.

Setup Check

Having selected the port you can check by using the Menu:

Menu > Tools

Arduino IDE board setup

If you selected the board correctly (and the Arduino was plugged in) then you will see the Board and Port in use, similar to the above image.

Run your First Program

Using the serial Port

As well as loading programs into the Arduino you can use the USB serial link yourself to communicate with the board. Typically you will output information to the PC screen (from the Arduino) and quite often use this output to debug what is going on in the program. But for now lets just get some text output from the Arduino.

This program is going to output "Hi there" using the serial monitor built into the Arduino IDE.

First of all : Copy and paste the following program into the white text area of the IDE replacing what is already there.

void setup() {
  Serial.Begin(9600);
  Serial.println("Hi there.");
}

void loop() {
}

Once you have done that hit the save button in the IDE and save the program as hi-there. The tab in the IDE will change to the text hi-there as below.

First program Arduino IDE

Compiling and Uploading

The tick mark on the left is the verify button - this verifies that your code is correct. The right arrow is the upload button. You only need to hit this button as preferences default to verify first then upload.

So hit the upload button.

Observe what happens.

it didn't work!

There was an error in the code!


Click to show error screen

Arduino Error screen
You can see that the line with the error is highlighted in pink and the error message is repeated in orange bar and in the black panel. If there are many errors you can expand the black panel to see them all.

In C/C++ programming you have to be very accurate in the words used - even putting a capital letter instead of lower case one (as here) means that the program will not compile.

The problem is that the word 'Begin' should be all-lowercase.

You will get used to these "syntax errors" and as you get used to programming will have fewer and fewer of these types of error.

If you don't know why an error occurred then search for 'Serial' in the Arduino reference - this gives you the details of functions you can use.

The main serial reference is here
and the specific information is here (found by clicking begin() from within the link above).

Lets correct the error and contine

To correct the error simply change the capital 'B' to lowercase 'b'.

void setup() {
  Serial.begin(9600);
  Serial.println("Hi there.");
}

void loop() {
}

Then save the file again. Now click the right arrow upload button again.

The right arrow will change to an orange background during the compilation and upload process:

Arduino IDE compile and upload

When compilation is complete you'll get a status report showing how much memory has been used for Flash and RAM.

Flash is the program storage area (fixed data - contents kept on power down) and for the Arduino Uno is 32kBytes, while RAM is the variable storage area (changing data - contents lost on power down) and for the Arduino Uno is 2kBytes.

The following image shows that program summary:

Arduino IDE uploaded
You can scroll the bottom message but the contents is:

Sketch uses 1488 bytes (4%) of program storage space.
Maximum is 32256 bytes.
Global variables use 198 bytes (9%) of dynamic memory, leaving 1850 bytes for local variables. Maximum is 2048 bytes.

When you create larger programs you may need to keep an eye on these numbers so you don't run out (of course you could use an Arduino Mega2560 that has 256k Flash and 8k RAM!).

Arduino IDE upload

Observe that the two green LEDs on the Arduino Uno are flashing during the upload process (this is a small program so it will be for a short time). Uploading begins immediately compilation is complete. The LEDs indicate that communication is working in both directions between the PC and the Uno.

You may need to re-upload to see this as it is quite a short upload time for this small program.

Open the Arduino IDE Serial monitor

To see the output data from the Arduino Uno start the serial monitor either by clicking the magnifying glass at top right of the Arduino IDE or using the menu:

Menu > Tools > Serial Monitor

Serial output from The Arduino Uno

The output you should see is shown below:

arduino IDE  serial monitor

You can see the output from the Arduino Uno in the main window. If you don't see it make sure you set the Baud rate in the above window (bottom right) to 9600 baud.

To make the Arduino output the data again press the reset button on the Arduino Uno (top left of the board).

So that completes installing, and setting up the Arduino IDE. You have also programmed the Arduino Uno with your first program and should now be familiar with programming the Arudino Uno with code.


New! Comments

Have your say about what you just read! Leave me a comment in the box below.




Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:
To Visit Click Here


Recent Articles

  1. ESP8266 Arduino IDE setup.

    Easily use an ESP8266 with the Arduino IDE and program your first sketch into the ESP8266

    Read more

  2. AD9833 a versatile easy to use signal generator on a chip

    Find out how to use the AD9833 to generate sine, square and triangle waves at 0.1Hz resolution.

    Read more

  3. Arduino map - map a value from one range to another

    Arduino map is a useful function but it may not do what you expect. Find out here how to use if correctly.

    Read more

  4. Arduino joystick tutorial: how to setup and use one on the Arduino

    How to test and use an Arduino Joystick including a new library to make it super easy.

    Read more

  5. Digispark Attiny85 Easy IDE install and setup

    Digispark ATtiny85: Essential information on setting up and using this tiny, but powerful, chip

    Read more

  6. Arduino Ide

    How to use the Arduino IDE: Beginners programming course.

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon

Back to Top