0% found this document useful (0 votes)
142 views4 pages

Introduction To Arduino Ide

The document provides an introduction to the Arduino IDE, explaining that it is used to write code and upload it to physical Arduino boards, and outlines the basic structure of Arduino programs including the setup and loop functions, as well as explaining how to connect sensors to analog and digital pins on the microcontroller.

Uploaded by

Rupankar Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views4 pages

Introduction To Arduino Ide

The document provides an introduction to the Arduino IDE, explaining that it is used to write code and upload it to physical Arduino boards, and outlines the basic structure of Arduino programs including the setup and loop functions, as well as explaining how to connect sensors to analog and digital pins on the microcontroller.

Uploaded by

Rupankar Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION TO ARDUINO IDE

The Arduino IDE


The Arduino IDE (Integrated Development Environment) is used to write the computer code
and upload this code to the physical board. The Arduino IDE is very simple and this simplicity
is probably one of the main reason Arduino became so popular. We can certainly state that
being compatible with the Arduino IDE is now one of the main requirements for a new
microcontroller board. Over the years, many useful features have been added to the
Arduino IDE and you can now managed third-party libraries and boards from the IDE, and
still keep the simplicity of programming the board. The main window of the Arduino IDE is
shown below, with the simple simple Blink example.

Downloading Arduino IDE Software


You can get different versions of Arduino IDE from the Download page on the Arduino
Official website. You must select your software, which is compatible with your operating
system (Windows, IOS, or Linux). After your file download is complete, unzip the file to
install the Arduino IDE.
Power up your board
The Arduino Uno, Mega and Arduino Nano automatically draw power from either, the USB
connection to the computer or an external power supply.

Launch the Arduino IDE. Connect the Arduino board to your computer using the USB cable.
Some power LED should be ON.

Your first Arduino project


Once the software starts, you have two options: you can create a new project or you can
open an existing project example.

To create a new project, select File → New. And then edit the file.

To open an existing project example, select File → Example → Basics → (select the example
from the list).

For explanation, we will take one of the simplest of examples named "AnalogReadSerial". It
reads a value from analog pin A0 and print it.

// the setup routine runs once when you press reset:


void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:


void loop()
{
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}

Basic programming of the Arduino


Sketch − The first new terminology is the Arduino program called “sketch”.

Arduino programs can be divided in three main parts: Structure, Values (variables and
constants), and Functions.

Let us start with the Structure. Software structure consist of two main functions:
Setup() function
The setup() function is called when a sketch starts. It is used to initialize the variables, pin
modes, start using libraries, etc. The setup function will only run once, after each power up
or reset of the Arduino board. Here, you can see the Serial.begin(9600); statement which
opens the serial port to allow the board to send output for display by the serial monitor (see
"Output" sub-section below).
Loop() function
After calling the setup() function, which initializes and sets the initial values,
the loop() function does precisely what its name suggests, and loops consecutively, allowing
your program to change and respond. It is used to actively control the Arduino board. Here,
you can see how a value is read from an analog pin (see "Understanding microcontroller
pins" sub-section below), then displayed with the Serial.println(sensorValue); statement.
Most of the information on this page is taken from here. There are other tutorials which one
might find interesting for understanding the electronics and programming an arduino board
like the one here on Sparkfun.

Understanding microcontroller pins


Microcontrollers, as opposed to microprocessors, usually have analog and digital pins that
can be easily controlled either as input or output pin. Reading from a physical sensor is
generally realized through an input while control or actuation is generally realized through
an output. An analog and a digital pin is internally attached to a analog-digital converter
(ADC) which provides the feature of converting a range on voltage, e.g. 0-3.3V, into a range
of numerical values, e.g. 0-1023. A digital pin can generally only have a LOW level (OV for
instance) and a HIGH level (3.3V for instance).

In the figure below is illustrated the popular ATmega328P 8-bit microcontroller that is used
to equip the Arduino Uno, Nano and ProMini boards. You can see, from left to right, the real
chip, then the schematic with the pin layout, and finally the Arduino Uno and ProMini
boards that expose the microcontroller pins on header pins.
If you have an analog physical sensor such as an analog LM35DZ temperature sensor, then
you need to connect it to an analog pin. If you have a digital sensor, it means that the
sensed value is not represented by a linear function of the voltage, but with an appropriate
digital coding of the value. Depending on the coding, you have to drive (e.g. read) the digital
pin accordingly in order to determine the numerical value. But, usually, this is done through
already written sensor or communication libraries such as the OneWire library for digital
sensors using the OneWire format. A digital sensor can be connected to an analog pin if only
LOW and HIGH level are used. However, it is a safe habit to use a digital pin for digital
sensors, unless specified differently by the sensor or communication library.

You might also like