ARDUINO IDE AND FIRST CODE

ARDUINO IDE AND FIRST CODE-Uncategorized

INTRO

In this tutorial, we will explain how to change settings inside Arduino IDE, how to “compile” and how to “upload”. Besides, we will start our first code blink, which can be found in Arduino Examples.

INITIAL SETTINGS

On the first start-up, Arduino IDE settings are default and it is required to define them correspondingly to Dasduino board which we are using. This won’t be hard, it’s about changing only few settings, depending on which Arduino IDE version we are using. Also, it is required to set them only once per board. Dasduino Core is using ATmega328 and this is the correct settings selection:

1. Tools – Board: – Arduino Nano

*NOTE: on some forums and comments we found that Dasduino board needs to be set to Arduino Duemilanove, which isn’t completely wrong. However, with those settings you won’t be able to use analog pins A6 and A7.

2. Tools – Processor: – ATmega328

Older versions of Arduino IDE don’t have “Processor” category, yet you can select it inside “Boards” category. That way, for Dasduino, under “Boards” you select “Arduino Nano w/ ATmega328”

3. Tools – Port – COM?

*NOTE: “?” presents the number of COM port which is given to the board by OS.

 

 

 

HOW TO USE IT?

Arduino software (IDE) is open-source, or programming language with open-source code which serves to write and upload code to Arduino boards. IDE stands for Integrated development environment.

IDE by itself consists of several parts: menu(izbornik),fast access section(brzi izbornik), text editor(tekstualni editor) and console(konzola). Below, we’ll talk more about those.

For now, I wouldn’t describe drop-down menu individually, we’ll use it only in special circumstances which have their own tutorials anyway.

Fast access section
Inside fast access section, there are shortcuts for most used commands. So let’s move on:

 

play Verify
Checks for possible errors in the code.

export Upload
Checks the code and uploads it to the board.
If you are using an external programmer, hold Shift key while you are clicking on the icon. Text “Upload” will change to “Upload using Programmer”.

new New
Creates new sketch.

open Open
Opens a menu with all sketches which could be found inside Arduino folders “Examples” and “Sketchbook”

save Save
Saves sketch to Arduino folder “Sketchbook”

serial_monitor Serial Monitor
Opens a Serial Monitor window. We’ll talk about it later in the tutorial.

Text editor
A text editor is a section which we use to type our code.

Console
A console is giving us some basic information about our sketch which we wrote inside the text editor.

 

Blink is a program which we will use to test if we have done all the steps right up to now: Arduino IDE installation, drivers installation and software adjustment. Code for Blink can be found in “Examples” which come with Arduino IDE, so we’ll load the code first.

Furthermore, there is a built-in led diode on pin 13, it is an orange LED diode and it’s placed right under the already mentioned pin. It’s really useful because we don’t need to connect an external diode for this or similar kind of testing. The sketch which will open is the same like in the picture below. The only thing we need to do is to upload on our board and we can do that by click on Upload icon which we already introduced.

A picture is showing the process of uploading a sketch to the board. First part of the procedure is to make a check (“Compililing sketch”), then afterward, if there were no errors, the actual upload. In the end, if everything went alright, a message “Done uploading.” will show up and the orange LED will blink.

 

 

ERRORS AND HOW TO READ THEM

Arduino IDE is not famous for having a good errorlog, but still, some things can be read. We will show more inside next example/picture below.

First thing what we can notice is color changing console (orange), which is a sign that either there is a problem with the sketch or IDE cannot establish a connection with the board. In this case, it’s obvious that problem is inside the code. Console tells us where the error is (“In function `void loop()`”), it even colors the code line inside text editor which isn’t correct. Some versions of this software don’t provide us this information, but we can still read them out of “Blink:25” part of the error, where Blink stands for the name of the sketch and 25 is the code line which has the error. Except where there is an error in the code, sometimes we can even get an information about what an actual error is. In this example, it is the line`high` was not declared in this scope and computer can’t recognize a variable high. If you’ve been playing with Arduino already, you’ll be able to recognize the correct name of variable HIGH easily. If not, continue to read our tutorials and video lessons and you’ll be able to overcome such obstacles really fast.

 

 

I HAVE A PROBLEM

You did everything like shown in the tutorials, but still you cannot upload your code to the board. You keep getting error from the picture below:

Try to check out next: under Tools – Port, do you still have the COM port which was given to you when you installed drivers? Hm, most likely not. Frustrating, especially because the same board sometimes works and sometimes it doesn’t and you are sure that drivers and USB cable aren’t bad.
It is because some versions of Arduino IDE software aren’t stable, for example, this 1.6.4 which we are using in the tutorial. For sure, this bug will be fixed soon with newer versions of software and drivers, until then, you can use some of the older/stable versions.
If you are using Mac OSX with this new version of Arduino IDE software, make sure you uninstall OS’s default drivers. How? You can find that out in this tutorial.