Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Arduino Notes - IoT

Uploaded by

Prof. Alamma B H
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Arduino Notes - IoT

Uploaded by

Prof. Alamma B H
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Arduino Notes

Definition :
Arduino is a prototype platform (open-source) based on easy-to-use hardware and software. It
consists of a circuit board, which can be programmed (referred to as a microcontroller) and an
open source software called Arduino IDE (Integrated Development Environment), which is
used to write and upload the computer code to the physical board.

Hardware Description :
The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital
input/output pins, 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack,
memory and a reset button.

Programming basic Syntax :


The arduino code is written in a simple programming language similar to C and C++. The
following are the syntax and its respective condition description.

1. Brackets
There are two types of brackets used in the Arduino coding, 1) Parentheses ( ) and 2) 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 - ' } '

2. Line Comment

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

● 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.
● 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 / *.

Programming LED Blinking :

void setup ()
{
pinMode ( 13, OUTPUT); // to set the OUTPUT mode of pin number 13.
}
void loop ()
{
digitalWrite (13, HIGH);
delay (4000); // 4 seconds = 4 x 1000 milliseconds
digitalWrite (13, LOW);
delay (1500); // 1.5 seconds = 1.5 x 1000 milliseconds
}

A. pinMode ( )
The specific pin number is set as the INPUT or OUTPUT in the pinMode () function.
The Syntax is: pinMode (pin, mode)
Where,
pin: It is the pin number. We can select the pin number according to the requirements.
Mode: We can set the mode as INPUT or OUTPUT according to the corresponding pin number.

B. digitalWrite( )
The digitalWrite ( ) function is used to set the value of a pin as HIGH or LOW.
Where,
HIGH: It sets the value of the voltage. For the 5V board, it will set the value of 5V, while for
3.3V, it will set the value of 3.3V.
LOW: It sets the value = 0 (GND).
If we do not set the pinMode as OUTPUT, the LED may light dim.
The syntax is: digitalWrite( pin, value HIGH/LOW)

C. delay ( )
The delay () function is a blocking function to pause a program from doing a task during the
specified duration in milliseconds.
For example, - delay (2000)
Where, 1 sec = 1000 millisecond
Hence, it will provide a delay of 2 seconds.
Case Study :

Pin 1 : Power USB


Arduino board can be powered by using the USB cable from your computer. All you
need to do is connect the USB cable to the USB connection (1)
Pin 2 : Power (Barrel Jack)
Arduino boards can be powered directly from the AC mains power supply by
connecting it to the Barrel Jack (2)
Pin 3 : Voltage Regulator
The function of the voltage regulator is to control the voltage given to the Arduino
board and stabilize the DC voltages used by the processor and other elements.

Pin 4 :Crystal Oscillator


The crystal oscillator helps Arduino in dealing with time issues. It helps to calculate the time
and the crystal frequency is 16,000,000 Hertz or 16 MHz.
Pin 5-17 : Arduino Reset
This pin is used to reset the whole system. It induces two modes 1) Reset button on the board
and 2) External device reset to the Arduino board.
Pin 6-9 : Pins (3.3, 5, GND, Vin)
●3.3V (6) − Supply 3.3 output volt
●5V (7) − Supply 5 output volt
●GND (8)(Ground) − There are several GND pins on the Arduino, any of which
can be used to ground your circuit.
●Vin (9) − This pin also can be used to power the Arduino board from an
external power source, like AC mains power supply.
Pin 10 : Analog pins
The Arduino UNO board has five analog input pins A0 through A5. These pins can read the signal from
an analog sensor like the humidity sensor or temperature sensor and convert it into a digital value that
can be read by the microprocessor.
Pin 11 : Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the brain of your boar
Pin 12 : ICSP pin
ICSP (In-Circuit Serial Programming) pins are for bypassing the USB port and interfacing the Arduino
directly as a serial device. This port is necessary to re-bootload your chip if it corrupts and can no longer
be connected to your computer
Pin 13 : Power LED indicator
This LED should light up when you plug your Arduino into a power source to
indicate that your board is powered up correctly. If this light does not turn on, then
there is something wrong with the connection.
Pin 14 : TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive). They appear
in two places on the Arduino UNO board. First, at the digital pins 0 and 1, to
indicate the pins responsible for serial communication. Second, the TX and RX led
(13). The TX led flashes with different speed while sending the serial data. The
speed of flashing depends on the baud rate used by the board. RX flashes during
the receiving process.
Pin 15 : Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse
Width Modulation) output. These pins can be configured to work as input digital
pins to read logic values (0 or 1) or as digital output pins to drive different modules
like LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.
Pin 16 : AREF
AREF stands for Analog Reference. It is sometimes used to set an external
reference voltage (between 0 and 5 Volts) as the upper limit for the analog input
pins.

You might also like