0% found this document useful (0 votes)
59 views43 pages

Lec-IoT-III (EC-702)

The document provides an overview of Arduino, an open-source platform for building electronics projects, detailing its hardware, software, and various applications. It covers different types of Arduino boards, their features, and how to interact with sensors and shields for enhanced functionalities. Additionally, it discusses programming basics using the Arduino IDE and the concepts of input and output in Arduino projects.

Uploaded by

Aniket
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)
59 views43 pages

Lec-IoT-III (EC-702)

The document provides an overview of Arduino, an open-source platform for building electronics projects, detailing its hardware, software, and various applications. It covers different types of Arduino boards, their features, and how to interact with sensors and shields for enhanced functionalities. Additionally, it discusses programming basics using the Arduino IDE and the concepts of input and output in Arduino projects.

Uploaded by

Aniket
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/ 43

Internet of Things

(EC-702)
Dr. Sudeep Sharma
IIIT Surat
[email protected]
Outline
➢Introduction to Arduino
➢Arduino Hardware
➢Arduino Software
➢Hardware and Software Interactions
➢Arduino types
➢Sensors
➢Shields
➢References
What is an Arduino?
➢Arduino is an open-source platform used for building
electronics projects.
➢ Arduino consists of both a physical programmable circuit
board and a piece of software, or IDE (Integrated
Development Environment).
➢Arduino does not need a separate piece of hardware (called
a programmer) in order to load new code onto the board-
you can simply use a USB cable.
➢The Arduino IDE uses a simplified version of C++, making
it easier to learn to program.
➢Arduino breaks out the functions of the micro-controller
into a more accessible package.
What Arduino can do?
Arduino can interact with
➢Switches,
➢LEDs,
➢Motors,
➢Speakers,
➢GPS units,
➢Cameras,
➢The internet,
➢Smart-phones
Source: https://openhomeautomation.net/best-arduino-starter-kit
➢TVs and many other devices.
Arduino Applications
➢Industrial Control
➢Automation
➢Robotics
➢Networking
➢Custom protocols
➢Healthcare
➢Monitoring etc
Source: https://makezine.com/projects/build-your-own-arduino-controlled-robot/
Arduino Hardware
➢There are many types of Arduino boards that can be used
for different purposes.
➢Most Arduinos have the majority of these components in
common:

Source: http://rookieelectronics.com
Popular Arduino Boards

➢ Arduino Uno
➢ Arduino Leonardo
➢ Arduino Mega
➢ Arduino Micro
➢ Arduino LilyPad
➢ Arduino Pro etc.

Source: https://cdn.sparkfun.com/assets/7/1/9/0/c/5228fb7a757b7fb7568b456d.png
Features of Arduino Uno
➢ Microcontroller ATmega328
➢ Operating Voltage 5V and 3.3V
➢ Input Voltage(recommended) 7-12V
➢ Input Voltage(limits) 6-20V
➢ Digital I/O Pins 14 (of which 6 provide
PWM output)
➢ Analog Input Pins 6
➢ DC current per I/O Pin 40mA
➢ DC current for 3.3V Pin 50mA
➢ Flash Memory 32KB (0.5KB used by
Bootloader)
➢ SRAM 2 KB (ATmega328)
➢ EEPROM 1 KB (ATmega328)
➢ Clock Speed 16MHz
ATmega328
Arduino Uno
➢ Functional parts of an Arduino.

(source: Making Things Talk 2nd edition)


Arduino software (IDE )
➢ The Arduino IDE (Integrated Development
Environment) is used to write the code for
Arduino.
➢ The current IDE version is IDE 2.0.1
➢ It is for free and can be downloaded from
:https://www.arduino.cc/en/Main/Software
➢ IDE uses simplified C++.
➢ Programs are called 'sketches'.
➢ Sketches need two functions:
➢ void setup( )
➢ void loop( )
➢ setup( ) runs first and once.
➢ loop( ) runs over and over, until power is
lost or a new sketch is loaded.

Source: http://arduino.cc
Arduino IDE Toolbar

➢Verify: button is used to check if the sketch is error-free.


➢Upload: button is used to upload the sketch to Arduino.
➢New: button is used to create new sketch.
➢Open button will present you with a list of sketches stored
within your sketchbook as well as a list of examples.
➢Save button will save the sketch.
➢Serial Monitor is a very useful tool, especially for debugging
your code.
➢In order to observe the serial data we have to setup the serial
communication.
Serial Communication

• Compiling turns your program into


binary data (ones and zeros)
• Uploading sends the bits through
USB cable to the Arduino
• The two LEDs near the USB
connector blink when data is
transmitted
• RX blinks when the Arduino is
receiving data
• TX blinks when the Arduino is
transmitting data
todbot.com/blog/bionicarduino
Serial Communication
• First you need to setup serial communication
• Serial.begin(9600); Typically, in setup()
• 9600 is the default speed (bps).
• Two main functions for printing information on the computer.
• Serial.print(“text”); Prints the word “text” on the screen
repeatedly.
• Serial.println(“text”); Will pass a line break after “text”. The
next command will result in printing on a new line.
• What is printed depends on the data type of the variable being passed
to the function.
Select Serial Port and Board in IDE

Source: http://arduino.cc
IDE Status Messages

Source:todbot.com/blog/bionicarduino
Data Representation
➢Typically computers store and transmit information digitally
as a collection of bits.

➢Each bit has two states:


➢ on/off
➢ true/false
➢ high/low
➢ 1/0

➢A byte is a collection of 8 bits


➢ An 8-bit byte can encode 256 different states
Data Types
Data type Size Number Range
boolean 1 byte 0 to 1 (True or False)
char 1 byte -128 to 127
unsigned char 1 byte 0 to 255
int 2 byte -32,768 to 32,767
unsigned int 2 byte 0 to 65,535
word 2 byte 0 to 65,535
long 4 byte -2,147,483,648 to
2,147,483,647
unsigned long 4 byte 0 to 4,294,967,295
float 4 byte -3.4028235E+38 to
3.4028235E+38
double 4 byte -3.4028235E+38 to
3.4028235E+38
string 1 byte + x Arrays of chars
array 1 byte + x Collection of variables

it is essential that we use only the smallest


variable data type necessary for our purpose.
Concepts: INPUT vs. OUTPUT

Inputs is a signal / information Output is any signal exiting the


going into the board. board.

Almost all systems that use physical computing will have some form of output

What are some examples of Outputs?


Concepts: INPUT vs. OUTPUT
Referenced from the perspective of the microcontroller (electrical board).

Inputs is a signal / information Output is any signal exiting the


going into the board. board.

Examples: Buttons Switches, Light Examples: LEDs, DC motor, servo


Sensors, Flex Sensors, Humidity motor, a buzzer, relay, an RGB LED
Sensors, Temperature Sensors…
Arduino Digital Output
//There is a LED connected to pin 13 on Arduino
board

void setup()
Digital output pins can {
be HIGH (5V) or LOW pinMode(13, OUTPUT); // sets pin 13 as
output
(0V).
}
Before we use a digital
output we need to set void loop()
the “pinMode” {
digitalWrite(13, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(13, LOW); // sets the LED off
delay(1000); // waits for a second
}

http://arduino.cc/en/Reference/DigitalWrite
Arduino Digital Input
int ledPin = 13; // LED connected to digital pin 13
int inPin = 2; // pushbutton connected to digital pin 7
boolean val = 0; // variable to store the read value

void setup()
Digital input pins can be {
HIGH (2.7V-5V) or pinMode(ledPin, OUTPUT);
LOW (1.2V-0V). // sets the digital pin 13 as output
Before you use a digital pinMode(inPin, INPUT);
// sets the digital pin 2 as input
input you need to set the }
“pinMode”
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val);
// sets the LED to the button's value
}
http://arduino.cc/en/Reference/DigitaRead
Arduino Analog Input
➢Analog Signal– Value is continuous not discretized

➢Analog Inputs allow us to read analog voltage signals


…but first we have to discretize them.

➢The Arduino Uno have a 10-bit analog to digital converter A/D

➢Voltages from 0V to 5V are scaled to the integers from 0 to 1023

Input Voltage Digital Output

0V ADC 0

2.5 V ADC 255

5.0 V ADC 1023


todbot.com/blog/bionicarduino
Arduino Analog Input
int analogPin = A0; // potentiometer wiper (middle terminal)
// connected to analog pin A0
// outside leads to ground and +5V
int val = 0; // variable to store the value read

void setup()
{
Serial.begin(9600); // setup serial
}

void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}

http://arduino.cc/en/Reference/AnalogRead
Arduino Analog Output
➢The Arduino Uno (like other Arduino boards) does not have a true analog
output. Instead it can create a pulse width modulation (PWM) signal on analog
output pins.

➢PWM Turns on and off rapidly. Duty cycle of the pulse can be adjusted, which
controls the average power output of the pin

➢Pins marked with ~ can be used as


analog output pins.

➢The ‘analogWrite’ function takes two


inputs: The pin number and a value
between 0 and 255 (8-bit)

http://arduino.cc/en/Tutorial/PWM
Arduino Analog Output
➢ Sets the output to the LED proportional to the value read from the potentiometer.

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


int analogPin = A0; // potentiometer connected to analog pin A0
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);
} Source: fritzing

http://arduino.cc/en/Reference/AnalogWrite
Arduino Types
➢Many different versions
➢Number of input/output channels
➢Processor
➢Leonardo
➢Mega
➢Due
➢Micro
➢LilyPad
➢Esplora
➢Uno
Source :https://www.quora.com/What-are-the-differences-between-Arduino-boards
Arduino Leonardo
• Compared to the Uno, a slight upgrade.
• Built in USB compatibility.

https://encryptedtbn0.gstatic.com/images?q=tbn
Arduino Mega
➢Compared to the Uno
➢Many more communication pins
➢More memory

https://c.76.my/Malaysia/[email protected]
Arduino Due
➢Much faster processor, many more pins.
➢Operates on 3.3 volts
➢Similar to the Mega

https://robokits.co.in/bmz_cache.image.981x508.jpg
Arduino Micro
➢When size matters: Micro, Nano, Mini
➢Includes all functionality of the Leonardo
➢Easily usable on a breadboard

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9Gc
Arduino LilyPad
➢LilyPad is popular for clothing-based projects.

https://encryptedtbn0.gstatic.com/images
Arduino Esplora
➢Game Controller
➢Includes joystick, four buttons, linear potentiometer
(slider), microphone, light sensor, temperature
sensor, three-axis accelerometer.
➢Not the standard set of IO pins.

https://cdn.shopify.com/s/files/1/0271/0223/products/esplora01
Sensors
➢With some simple code, the Arduino can control and
interact with a wide variety of sensors such as
➢ Light,
➢Temperature,
➢Pressure,
➢Proximity,
➢Distance
➢Speed
➢Acceleration,
➢Radioactivity,
➢Humidity and many more

Source: https://www.robotshop.com/en/37-modules-sensor-kit-arduino-v2.html
Arduino Shields
➢Shields – are pre-built circuit boards that fit on top of your
Arduino and provide additional capabilities such as
➢ Controlling Motors,
➢ Connecting to the Internet,
➢ Cellular or Wireless Communication,
➢Controlling an LCD screen, and much more.

Source: MakeUseOf.com
https://cdn.sparkfun.com/assets/3/d/8/6/1/5144cc2bce395fb170000002.jpg
Arduino Shields
➢Ethernet Shield – The Ethernet Shield allows you to connect your
Arduino to the internet . You just have to plug the shield onto the
Arduino board and then, connect it to your network.

Source: Google Images


Arduino Shields
➢Relay Shield– The Relay Shield is a module with 4 mechanical
relays that provides you an easy way to control high voltage.

Source: Google Images


Arduino Shields
➢ProtoShield– The ProtoShield is a prototyping Shield that makes
it easy to prototype. It allows for easy connections between the
breadboard and the Arduino.

Source: Google Images


Arduino Shields
➢Motor Shield– This Shield allows an easy control of motor
direction and speed. It makes it easy to incorporate a motor into
any of your projects.

Source: Google Images


Arduino Shields
➢Camera Shield– With this Shield it is possible to reduce the
complexity of the camera control interface.

Source: Google Images


Arduino Shields
➢ESP8266 Wi-Fi Shield– ESP8266 Wi-Fi Shield is an Arduino
compatible shield for the ESP8266 WiFi SoC – a leading platform
for Internet of Things (IoT) or Wi-Fi related projects.

Source: Google Images


Reference Books
➢Beginning Arduino by Michael McRoberts.

➢Arduino Development Cookbook by Cornel Amariei.

➢Introduction to Arduino A piece of cake! by Alan G. Smith.

➢Electronics Cookbook Practical Electronic Recipes with


Arduino and Raspberry Pi by Simon Monk .

➢Making Things Talk by Tom Igoe.


Thank You

You might also like