0% found this document useful (0 votes)
120 views11 pages

Final Year Django

The document discusses an experiment on studying the Arduino board and its integrated development environment (IDE). It provides an overview of Arduino, describing it as an open-source electronics platform that can read sensor inputs and produce outputs. It explains the key features of Arduino boards, how to program them using the Arduino IDE, and the basic structure of Arduino programs. The document also describes common Arduino functions like pinMode(), digitalRead(), digitalWrite(), analogRead(), and analogWrite(). It concludes by discussing how to simulate Arduino circuits and program them using the TinkerCad simulation software.

Uploaded by

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

Final Year Django

The document discusses an experiment on studying the Arduino board and its integrated development environment (IDE). It provides an overview of Arduino, describing it as an open-source electronics platform that can read sensor inputs and produce outputs. It explains the key features of Arduino boards, how to program them using the Arduino IDE, and the basic structure of Arduino programs. The document also describes common Arduino functions like pinMode(), digitalRead(), digitalWrite(), analogRead(), and analogWrite(). It concludes by discussing how to simulate Arduino circuits and program them using the TinkerCad simulation software.

Uploaded by

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

Department of Information Technology

Academic Year: 2020-21 Semester: VI


Subject: IoT Mini-project Lab Class / Branch: TE IT

Experiment 2

1. Aim: To Study Arduino Board and its Intergrated Developement Environment(IDE)

2. Objective:
a) To learn the Arduino language (syntax and structure, variables and
keyword, Control Structure, Basic Functions etc)
b) Understanding Arduino commands with examples

3. Theory:

What is Arduino?

 Arduino is an open-source electronics platform based on easy-to-use hardware


and software.
 Arduino boards are able to read inputs - light on a sensor, a finger on a button,
or a Twitter message - and turn it into an output - activating a motor, turning on
an LED, publishing something online.
 You can tell your board what to do by sending a set of instructions to the
microcontroller on the board.
 To do so you use the Arduino programming language (based on Wiring), and
the Arduino Software (IDE), based on Processing.

The key features are –

 Arduino boards are able to read analog or digital input signals from different
sensors and turn it into an output such as activating a motor, turning LED
on/off, connect to the cloud and many other actions.
 You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading
software).
 Unlike most previous programmable circuit boards, Arduino does not need an
extra piece of hardware (called a programmer) in order to load a new code onto
the board. You can simply use a USB cable.
 Additionally, the Arduino IDE uses a simplified version of C++, making it
easier to learn to program.

Subject Incharge: Ms. Sonal Jain Department of Information Technology


Arduino Uno Board Description

Subject Incharge: Ms. Sonal Jain Department of Information Technology


Components introduction that we are going to work with

Subject Incharge: Ms. Sonal Jain Department of Information Technology


Download the Arduino Software (IDE)

Get the latest version from the download page. You can choose between the Installer (.exe)
and the Zip packages. We suggest you use the first one that installs directly everything you
need to use the Arduino Software (IDE), including the drivers. With the Zip package you need
to install the drivers manually. The Zip file is also useful if you want to create a portable
installation.
When the download finishes, proceed with the installation and please allow the driver installation
process when you get a warning from the operating system.

Choose the components to install

Choose the installation directory (we suggest to keep the default one)

Subject Incharge: Ms. Sonal Jain Department of Information Technology


The process will extract and install all the required files to execute properly the Arduino
Software (IDE)

Arduino Program Structure

StructureArduino programs can be divided in three main parts: Structure,


Values(variables and constants), and Functions.

Software structure consist of two main functions:

 Setup( ) function
 Loop( ) function

1. pinMode()
[Digital I/O]

Description
Configures the specified pin to behave either as an input or an output. See the Digital
Pins page for details on the functionality of the pins.

Subject Incharge: Ms. Sonal Jain Department of Information Technology


As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode
INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal
pullups.

Syntax

pinMode(pin, mode)

Parameters

pin: the Arduino pin number to set the mode of.


mode: INPUT, OUTPUT, or INPUT_PULLUP. See the Digital Pins page for a more
complete description of the functionality.

Returns

Nothing

2. digitalRead()

[Digital I/O]
Description
Reads the value from a specified digital pin, either HIGH or LOW.

Syntax
digitalRead(pin)

Parameters
pin: the Arduino pin number you want to read

Returns
HIGH or LOW

3. digitalWrite()
[Digital I/O]

Description
Write a HIGH or a LOW value to a digital pin.
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set
to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for
LOW.

Subject Incharge: Ms. Sonal Jain Department of Information Technology


If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable
(LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to
INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial
for more information.
If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when
calling digitalWrite(HIGH), the LED may appear dim. Without explicitly setting
pinMode(), digitalWrite() will have enabled the internal pull-up resistor, which acts
like a large current-limiting resistor.

Syntax
digitalWrite(pin, value)

Parameters
pin: the Arduino pin number.
value: HIGH or LOW.

Returns
Nothing

Example Code

Sets pin 13 to the same value as pin 7, declared as an input. int


ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7 int
val = 0; // variable to store the read value

void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}

void loop() {
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}

4. analogRead()
[Analog I/O]

Description
Reads the value from the specified analog pin. Arduino boards contain a multichannel,
10-bit analog to digital converter. This means that it will map

Subject Incharge: Ms. Sonal Jain Department of Information Technology


input voltages between 0 and the operating voltage(5V or 3.3V) into integer values
between 0 and 1023. On an Arduino UNO, for example, this yields a resolution
between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit. See the
table below for the usable pins, operating voltage and maximum resolution for some
Arduino boards.
Syntax
analogRead(pin)

Parameters
pin: the name of the analog input pin to read from (A0 to A5 on most boards, A0 to
A6 on MKR boards, A0 to A7 on the Mini and Nano, A0 to A15 on the Mega).

Returns
The analog reading on the pin. Although it is limited to the resolution of the analog to
digital converter (0-1023 for 10 bits or 0-4095 for 12 bits). Data type: int.

5. analogWrite()
[Analog I/O]
Description
Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying
brightness’s or drive a motor at various speeds. After a call to analogWrite(), the pin
will generate a steady rectangular wave of the specified duty cycle until the next call to
analogWrite() (or a call to digitalRead() or digitalWrite()) on the same pin

Syntax
analogWrite(pin, value)

Parameters
pin: the Arduino pin to write to. Allowed data types: int. value: the
duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int.

Returns
Nothing

Subject Incharge: Ms. Sonal Jain Department of Information Technology


Example Code

Sets the output to the LED proportional to the value read from the
potentiometer.

int ledPin = 9; // LED connected to digital pin 9


int analogPin = 3; // potentiometer connected to analog pin 3 int val
= 0; // variable to store the read value

void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}

void loop() {
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023,
analogWrite values from 0 to 255
}

The simulation of Arduino and its component using open source simulation software
TinkerCad-

Simulated circuit using Arduino UNO


Subject Incharge: Ms. Sonal Jain Department of Information Technology
Electronic Components View

Serial Monitor View

Subject Incharge: Ms. Sonal Jain Department of Information Technology


Blocks, Codes and Programming on Tinkercad

Conclusion: Successfully learnt how to use the arduino IDE for compiling and
uploading the programs on the Arduino uno board and learnt the basic functions
needed to program using Arduino. Also we have studied the environment of open
source Simulation software Tinkercad.

Subject Incharge: Ms. Sonal Jain Department of Information Technology

You might also like