0% found this document useful (0 votes)
25 views7 pages

Internet of Things Chapter 4

Physical Devices and Endpoints

Uploaded by

tannu
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)
25 views7 pages

Internet of Things Chapter 4

Physical Devices and Endpoints

Uploaded by

tannu
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/ 7

Arduino UNO Pinout

The Arduino UNO is a standard board of Arduino, which is based on an ATmega328P microcontroller. It is easier to use than other
types of Arduino Boards.

The Arduino UNO Board, with the specification of pins, is shown below:

o ATmega328 Microcontroller- It is a single chip Microcontroller of the ATmel family. The processor core inside it is of 8-
bit. It is a low-cost, low powered, and a simple microcontroller. The Arduino UNO and Nano models are based on the
ATmega328 Microcontroller.
o Voltage Regulator

The voltage regulator converts the input voltage to 5V. The primary function of
voltage regulator is to regulate the voltage level in the Arduino board. For any changes in the
input voltage of the regulator, the output voltage is constant and steady.

o GND - Ground pins. The ground pins are used to ground the circuit.
o TXD and RXD

TXD and RXD pins are used for serial communication. The TXD is used for transmitting the data, and RXD is used for receiving the
data. It also represents the successful flow of data.

o USB Interface
The USB Interface is used to plug-in the USB cable. It allows the board to connect to the computer. It is essential for the
programming of the Arduino UNO board.

o RESET

It is used to add a Reset button to the connection.

o SCK

It stands for Serial Clock. These are the clock pulses, which are used to synchronize the transmission of data.

o MISO

It stands for Master Input/ Slave Output. The save line in the MISO pin is used to send the data to the master.

o VCC

It is the modulated DC supply voltage, which is used to regulate the IC's used in the connection. It is also called as the primary
voltage for IC's present on the Arduino board. The Vcc voltage value can be negative or positive with respect to the GND pin.

o Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the Arduino UNO a powerful board.
o ICSP

It stands for In-Circuit Serial Programming. The users can program the Arduino board's firmware using the ICSP pins.

The program or firmware with the advanced functionalities is received by microcontroller with the help of the ICSP header.

The ICSP header consists of 6 pins.

The structure of the ICSP header is shown below:

It is the top view of the ICSP header.

o SDA

It stands for Serial Data. It is a line used by the slave and master to send and receive data. It is called as a data line, while SCL is
called as a clock line.

o SCL
It stands for Serial Clock. It is defined as the line that carries the clock data. It is used to synchronize the transfer of data between
the two devices. The Serial Clock is generated by the device and it is called as master.

o SPI

It stands for Serial Peripheral Interface. It is popularly used by the microcontrollers to communicate with one or more peripheral
devices quickly. It uses conductors for data receiving, data sending, synchronization, and device selection (for communication).

o MOSI

It stands for Master Output/ Slave Input.

The MOSI and SCK are driven by the Master.

o SS

It stands for Slave Select. It is the Slave Select line, which is used by the master. It acts as the enable line.

o I2C

It is the two-wire serial communication protocol. It stands for Inter Integrated Circuits. The I2C is a serial communication protocol
that uses SCL (Serial Clock) and SDA (Serial Data) to receive and send data between two devices.

3.3V and 5V are the operating voltages of the board.

Arduino Coding Basics


We have already discussed the popular Arduino Boards, Arduino IDEs, and Installation process of the Arduino software. We learned
that Arduino IDE (Integrated Development Environment) allows us to draw the sketch and upload it to the various Arduino
boards using code. The code is written in a simple programming language similar to C and C++.

The initial step to start with Arduino is the IDE download and installation.

Let's discuss the basics to start with Arduino programming.

Brackets

There are two types of brackets used in the Arduino coding, which are listed below:

o Parentheses ( )
o Curly Brackets { }

Parentheses ( )

The parentheses brackets are the group of the arguments, such as method, function, or a code
statement. These are also used to group the math equations.

Curly Brackets { }
The statements in the code are enclosed in the curly brackets. We always require closed curly
brackets to match the open curly bracket in the code or sketch.

Open curly bracket- ' { '

Closed curly bracket - ' } '

Line Comment

There are two types of line comments, which are listed below:

o Single line comment


o Multi-line comment

// Single line comment

The text that is written after the two forward slashes are considered as a single line comment. The compiler ignores the code written
after the two forward slashes. The comment will not be displayed in the output. Such text is specified for a better understan ding of
the code or for the explanation of any code statement.

The // (two forward slashes) are also used to ignore some extra lines of code without deleting it.

/ * Multi - line comment */

The Multi-line comment is written to group the information for clear understanding. It starts with the single forward slash and an
asterisk symbol (/ *). It also ends with the / *. It is commonly used to write the larger text. It is a comment, which is also ignored by
the compiler.

Coding Screen

The coding screen is divided into two blocks. The setup is considered as the preparation block, while the loop is considered as the
execution block. It is shown below:

Arduino Syntax and Program Flow


Syntax

Syntax in Arduino signifies the rules need to be followed for the successful uploading of the Arduino program to the board. The
syntax of Arduino is similar to the grammar in English. It means that the rules must be followed in order to compile and run our code
successfully. If we break those rules, our computer program may compile and run, but with some bugs.

Let's understand with an example.

The two functions that encapsulate the pieces of code in the Arduino program are shown below:

1. void setup ( )
2. void loop ( )

Functions
o The functions in Arduino combine many pieces of lines of code into one.
o The functions usually return a value after finishing execution. But here, the function does not return any value due to the
presence of void.
o The setup and loop function have void keyword present in front of their function name.
o The multiple lines of code that a function encapsulates are written inside curly brackets.
o Every closing curly bracket ' } ' must match the opening curly bracket '{ ' in the code.

Spaces
o Arduino ignores the white spaces and tabs before the coding statements.
o The coding statements in the code are intent (empty spacing at the starting) for the easy reading.
o In the function definition, loop, and conditional statements, 1 intent = 2 spaces.
o The compiler of Arduino also ignores the spaces in the parentheses, commas, blank lines, etc.

Tools Tab
o The verify icon present on the tool tab only compiles the code. It is a quick method to check that whether the syntax of
our program is correct or not.
o To compile, run, and upload the code to the board, we need to click on the Upload button.

Uses of Parentheses ( )
o It denotes the function like void setup ( ) and void loop ( ).
o The parameter's inputs to the function are enclosed within the parentheses.
o It is also used to change the order of operations in mathematical operations.

Semicolon ;
o It is the statement terminator in the C as well as C++.
o A statement is a command given to the Arduino, which instructs it to take some kind of action. Hence, the terminator is
essential to signify the end of a statement.
o We can write one or more statements in a single line, but with semicolon indicating the end of each statement.
o The compiler will indicate an error if a semicolon is absent in any of the statements.
o It is recommended to write each statement with semicolon in a different line, which makes the code easier to read.
o We are not required to place a semicolon after the curly braces of the setup and loop function.
Arduino processes each statement sequentially. It executes one statement at a time before moving to the next statement.

Program Flow

The program flow in Arduino is similar to the flowcharts. It represents the execution of a program in order.

We recommend to draw the flowchart before writing the code. It helps us to understand the concept of code, which makes it the
coding simpler and easier.

Flow Charts

A flowchart uses shapes and arrows to represent the information or sequence of actions.

An oval ellipse shows the Start of the sequence, and a square shows the action or processes that need to be performed.

Arduino is an open-source platform that is a combination of hardware and software. Arduino is easily accessible - even for those
who don't know much about electronics. Arduino boards are simple a type of microcontroller. They are able to read inputs from the
sensors and turn those inputs into output.

Arduino is the best for beginners looking to get started with electronics for the first time. It features a combination of circuits,
coding, DIY, problem-solving, and creativity, that marries together thinking across disciplines. Today, we're going to guide you step-
by-step through getting your child started with Arduino.

Explore a step-by-step guide to setup the environment of Arduino


programming

Here's how to use the physical Arduino Uno board. The Arduino Uno is one among the several development boards. It has 14 digital
input/output pins, 6 analog input pins, a power jack, a reset button, a USB connection, an ICSP header.

1. Download & install the Arduino environment (IDE)

If you just got your Arduino Uno board, you’ll first have to install the Arduino IDE (Integrated Development Environment) on another
computer. The code is typed into the IDE and sent to the Arduino via a USB cable.

Visit arduino.cc to download the most recent Arduino IDE version for your computer. There are different versions for Mac, Windows,
and Linux OS.

 At the download page, click on the “Installer” option for the easiest installation then
 Save the .exe file to your disk drive.
 Open the .exe file.
 Click the button to agree to the licensing agreement
 Decide which components to put in, then click “Next”
 Select which folder to put in the program to, then click “Install”
 Wait for the program to complete installing, then click “Close”

2. Launch the Arduino IDE

After your Arduino IDE software is downloaded, unzip the folder. To do so, double-click on the Arduino shortcut on your Desktopt.
The IDE will open up and you’ll see the code editor.
3. If needed, install the drivers

If you used the Installer, it'll install drivers automatically as soon as you connect your board.

4. Connect the board to your computer via the USB cable

To power up your board, connect your Arduino board with the pc via USB cable. The green color power LED should glow on the
board.

5. Select your board

Next, make sure the software is ready up for your particular Arduino board. Go to the “Tools” computer menu from the menu bar.
Select the “Board” option and another menu will appear, where you'll select your Arduino model from the list.

6. Select your serial port

Select the serial device of the Arduino board. Go to Tools, and then the serial port menu. You might see COM3 or higher (COM1 and
COM2 are usually reserved for hardware serial ports). To find out which port your Arduino board is connected to, disconnect your
Arduino board and re-open the menu. The entry that disappears should be the Arduino board. Reconnect the board and choose that
serial port.

Open the blink example

We'll start with the LED Blink example that comes with the Arduino IDE. Just go to File->Examples->Basics->Blink.

Here are the few things to keep in mind while writing the code:

 Code is case sensitive


 All the statements must end with a semicolon
 Comments follow a // or begin with /* and end with */
 Void loop() and void setup() are two mandatory functions. The setup section of the code is simply run once when the
Arduino board is first turned on or reset. Once the setup is complete, the loop runs over and over. It keeps on running
until the board continues to stay powered.
 The status bar shows that the program is compiled or uploaded.
 Program notification area shows error(s) within the code if any.

Upload the program

Now it is time to upload your first sketch(code). Confirm the Arduino is plugged in, and the green light is on - therefore the correct
board and port is chosen. Select Upload from the Sketch drop-down menu.

You might also like