You are on page 1of 35

IoT and Applications-3160716

Practical: 1
Aim: Define IoT and enlist application areas related to IoT.
• IoT: The Internet of Things (IoT) describes the network of physical objects -“things”
- that are embedded with sensors, software, and other technologies for the purpose of
connecting and exchanging data with other devices and systems over the internet.
• Alternative definition of IoT:
• The Internet of Things, or IoT, refers to the billions of physical devices around the
world that are now connected to the internet, all collecting and sharing data.
• The internet of things, or IoT, is a system of interrelated computing devices,
mechanical and digital machines, objects, animals or people that are provided with
unique identifiers (UIDs) and the ability to transfer data over a network without
requiring human-to-human or human-to-computer interaction.
• Applications area related to IoT: The applications of IoT technologies are multiple,
because it is adjustable to almost any technology that is capable of providing relevant
information about its own operation, about the performance of an activity and even
about the environmental conditions that we need to monitor and control at a distance.
• Nowadays, many companies from different sectors are adopting this technology to
simplify, improve, automate and control different processes.
• Various applications related to IoT are:
• Wearables.
• Health.
• Traffic Monitoring.
• Agriculture.
• Hospitality.
• Smart grid and Energy Saving.
• Water supply.
• Maintenance management, etc.
• Wearables: Virtual glasses, fitness bands to monitor for example calorie expenditure
and heart beats, or GPS tracking belts, are just some examples
of wearable devices that we have been using for some time now. Companies such as
Google, Apple, Samsung and others have developed and introduced the Internet of
Things and the application thereof into our daily lives.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

• These are small and energy efficient devices, which are equipped with sensors, with
the necessary hardware for measurements and readings, and with software to collect
and organize data and information about users.
• Health: The use of wearables or sensors connected to patients, allows doctors to
monitor a patient's condition outside the hospital and in real-time. Through
continuously monitoring certain metrics and automatic alerts on their vital signs, the
Internet of Things helps to improve the care for patients and the prevention of lethal
events in high-risk patients.
• Another use is the integration of IoT technology into hospital beds, giving way to
smart beds, equipped with special sensors to observe vital signs, blood pressure,
oximeter and body temperature, among others.
• Traffic monitoring: The Internet of things can be very useful in the management of
vehicular traffic in large cities, contributing to the concept of smart cities.
• When we use our mobile phones as sensors, which collect and share data from our
vehicles through applications such as Waze or Google Maps, we are using the Internet
of Things to inform us and at the same time contribute to traffic monitoring, showing
the conditions of the different routes, and feeding and improving the information on
the different routes to the same destination, distance, estimated time of arrival.
• Agriculture: Smart farms are a fact. The quality of soil is crucial to produce good
crops, and the Internet of Things offers farmers the possibility to access detailed
knowledge and valuable information of their soil condition.
•  Information such as soil moisture, level of acidity, the presence of certain nutrients,
temperature and many other chemical characteristics, helps farmers control irrigation,
make water use more efficient, specify the best times to start sowing, and even
discover the presence of diseases in plants and soil.
• Hospitality: The application of the IoT to the hotel industry brings with it interesting
improvements in the quality of the service. With the implementation of electronic
keys, which are sent directly to the mobile devices of each guest, it is possible to
automate various interactions.
• Thus, the location of the guests, the sending of offers or information on activities of
interest, the realization of orders to the room or room service , the automatic charge of
accounts to the room or the request of personal hygiene supplies, are activities that
can be easily managed through integrated applications using the Internet of Things
technology.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

• With the use of electronic keys, the check-out process is automated, disabling the


operation of doors, offering information about the room’s immediately available, and
even assigning housekeeping tasks to maintenance personnel.
• Smart grid and energy saving: The progressive use of intelligent energy meters, or
meters equipped with sensors, and the installation of sensors in different strategic
points that go from the production plants to the different distribution points, allows
better monitoring and control of the electrical network.
• By establishing a bidirectional communication between the service provider company
and the end user, information of enormous value can be obtained for the detection of
faults, decision making and repair thereof.
• It also allows offering valuable information to the end user about their consumption
patterns and about the best ways to reduce or adjust their energy expenditure.
• Water supply: A sensor, either incorporated or adjusted externally to water meters,
connected to the Internet and accompanied by the necessary software , helps to
collect, process and analyze data, which allows understanding the behavior of
consumers, detecting faults in the supply service, report results and offer courses of
action to the company that provides the service.
• Maintenance management: One of the areas where the application of IoT
technology is most extensive is precisely maintenance management. 
• Through the combination of sensors and software specialized in CMMS/
EAM maintenance management, a multifunctional tool is obtained whose use can be
applied to a multiplicity of disciplines and practices, with the purpose of extending the
useful life of physical assets, while guaranteeing asset reliability and availability.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 2
Aim: Study about Arduino Uno.
Overview:
 Arduino Uno is a microcontroller board based on 8-bit ATmega328P
microcontroller. Along with ATmega328P, it consists other components such as
crystal oscillator, serial communication, voltage regulator, etc. to support the
microcontroller.
 Arduino Uno has 14 digital input/output pins (out of which 6 can be used as PWM
outputs), 6 analog input pins, a USB connection, A Power barrel jack, an ICSP header
and a reset button.
Arduino Uno Pin Description:

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Pin Description:
Pin Pin Name Details
Category
Power Vin, 3.3V, 5V, Vin: Input voltage to Arduino when using an external power source.
GND 5V: Regulated power supply used to power microcontroller and
other components on the board.
3.3V: 3.3V supply generated by on-board voltage regulator.
Maximum current draw is 50mA.
GND: ground pins.
Reset Reset Resets the microcontroller.
Analog Pins A0 – A5 Used to provide analog input in the range of 0-5V
Input/Output Digital Pins 0 - Can be used as input or output pins.
Pins 13
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.
External 2, 3 To trigger an interrupt.
Interrupts
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
SPI 10 (SS), 11 Used for SPI communication.
(MOSI), 12
(MISO) and 13
(SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
TWI A4 (SDA), A5 Used for TWI communication.
(SCA)
AREF AREF To provide reference voltage for input voltage.

Arduino Uno Technical Specifications

Microcontroller ATmega328P – 8 bit AVR family microcontroller


Operating Voltage 5V
Recommended Input Voltage 7-12V
Input Voltage Limits 6-20V

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Analog Input Pins 6 (A0 – A5)


Digital I/O Pins 14 (Out of which 6 provide PWM output)
DC Current on I/O Pins 40 mA
DC Current on 3.3V Pin 50 mA
Flash Memory 32 KB (0.5 KB is used for Bootloader)
SRAM 2 KB
EEPROM 1 KB
Frequency (Clock Speed) 16 MHz

How to use Arduino Board

The 14 digital input/output pins can be used as input or output pins by using pinMode(),
digitalRead() and digitalWrite() functions in arduino programming. Each pin operate at 5V
and can provide or receive a maximum of 40mA current, and has an internal pull-up resistor
of 20-50 KOhms which are disconnected by default.  Out of these 14 pins, some pins have
specific functions as listed below:
 Serial Pins 0 (Rx) and 1 (Tx): Rx and Tx pins are used to receive and transmit TTL
serial data. They are connected with the corresponding ATmega328P USB to TTL
serial chip.
 External Interrupt Pins 2 and 3: These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value.
 PWM Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using
analogWrite() function.
 SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for
SPI communication.
 In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is
HIGH – LED is on and when pin 13 is LOW, its off.

Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10 bits of
resolution, i.e. 1024 different values. They measure from 0 to 5 volts but this limit can be
increased by using AREF pin with analog Reference() function.  
 Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire
library.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Arduino Uno has a couple of other pins as explained below:


 AREF: Used to provide reference voltage for analog inputs with analogReference()
function.
 Reset Pin: Making this pin LOW, resets the microcontroller.

Communication

 Arduino can be used to communicate with a computer, another Arduino board or


other microcontrollers. The ATmega328P microcontroller provides UART TTL (5V)
serial communication which can be done using digital pin 0 (Rx) and digital pin 1
(Tx).
 An ATmega16U2 on the board channels this serial communication over USB and
appears as a virtual com port to software on the computer. The ATmega16U2
firmware uses the standard USB COM drivers, and no external driver is needed.
However, on Windows, a .inf file is required.
 The Arduino software includes a serial monitor which allows simple textual data to be
sent to and from the Arduino board.
 There are two RX and TX LEDs on the arduino board which will flash when data is
being transmitted via the USB-to-serial chip and USB connection to the computer (not
for serial communication on pins 0 and 1).
 A SoftwareSerial library allows for serial communication on any of the Uno's digital
pins.
 The ATmega328P also supports I2C (TWI) and SPI communication. The Arduino
software includes a Wire library to simplify use of the I2C bus.
Arduino Uno to ATmega328 Pin Mapping

When ATmega328 chip is used in place of Arduino Uno, or vice versa, the image below
shows the pin mapping between the two.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Software

Arduino IDE (Integrated Development Environment) is required to program the Arduino Uno
board.

Programming Arduino

 Once arduino IDE is installed on the computer, connect the board with computer
using USB cable.
 Now open the arduino IDE and choose the correct board by selecting
Tools>Boards>Arduino/Genuino Uno, and choose the correct Port by selecting
Tools>Port.
 Arduino Uno is programmed using Arduino programming language based on Wiring.
 To get it started with Arduino Uno board and blink the built-in LED, load the example
code by selecting Files>Examples>Basics>Blink.
 Once the example code (also shown below) is loaded into your IDE, click on the
‘upload’ button given on the top bar.
 Once the upload is finished, you should see the Arduino’s built-in LED blinking.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

 The structure of Arduino program is pretty simple. Arduino programs have a


minimum of 2 blocks,
 Preparation & Execution
 Each block has a set of statements enclosed in curly braces:
void setup( )
{
statements-1;
.
.
.
statement-n;
}
void loop ( )
{
statement-1;
.
.
.
statement-n;
}
 Here, setup ( ) is the preparation block and loop ( ) is an execution block.
 The setup function is the first to execute when the program is executed, and this
function is called only once. The setup function is used to initialize the pin modes and
start serial communication. This function has to be included even if there are no
statements to execute.
void setup ( )
{
pinMode (pin-number, OUTPUT); // set the ‘pin-number’ as output
pinMode (pin-number, INPUT); // set the ‘pin-number’ as output
}
 After the setup ( ) function is executed, the execution block runs next. The execution
block hosts statements like reading inputs, triggering outputs, checking conditions etc.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

 In the above example loop ( ) function is a part of execution block. As the name
suggests, the loop( ) function executes the set of statements (enclosed in curly braces)
repeatedly.
Void loop ( )
{
digitalWrite (pin-number,HIGH); // turns ON the component
connected to ‘pin-number’
delay (1000); // wait for 1 sec
digitalWrite (pin-number, LOW); // turns OFF the component
connected to ‘pin-number’
delay (1000); //wait for 1sec
}
 Note: Arduino always measures the time duration in millisecond. Therefore,
whenever you mention the delay, keep it in milli seconds.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 3
Aim: Using Arduino Uno implement blinking the LED experiment.
Overview: In the process of experimenting with Arduino, writing the Arduino program is not
the only important thing, building the breadboard circuit is equally important.
 Let’s take a look at how the breadboard circuit has to be built for both the
experiments.
 Components required:
 Arduino UNO R3 -1
 Breadboard -1
 Breadboard connectors -3
 LED -1
 1K resistor -1
Blinking LED
 Steps in building a breadboard connection:
 Step-1: Connect the Arduino to the Windows / Mac / Linux system via a
USB cable
 Step-2: Connect the 13th digital pin of Arduino to the positive power rail of
the breadboard and GND to the negative
 Step-3: Connect the positive power rail to the terminal strip via a 1K ohm
resistor
 Step-4: Fix the LED to the ports below the resistor connection in the
terminal strip
 Step-5: Close the circuit by connecting the cathode (the short chord) of the
LED to the negative power strip of the breadboard

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Arduino program for LED blink (Version-1)

int LED =13; // The digital pin to which the LED is connected
void setup ( )
{
pinMode (LED, OUTPUT); //Declaring pin 13 as output pin
}
void loop( ) // The loop function runs again and again
{
digitalWrite (LED, HIGH); //Turn ON the LED
delay(1000); //Wait for 1sec
digitalRead (LED, LOW); // Turn off the LED
delay(1000); // Wait for 1sec
}
Arduino program for LED blink (Version-2)
void setup ( )
{
pinMode (13, OUTPUT); //pin 13 is set as output pin
}
void loop( ) // The loop function runs again and again
{
digitalWrite (13,HIGH); // Turn ON the LED on pin 13
delay (1000); //Wait for 1sec
digitalWrite (13, LOW); //Turn OFF the LED on pin 13
}
 In version-1 of the LED blink program LED is declared globally and is set to pin
number 13. This will reduce the number of iterations required to update the pin
number in the program when you connect the LED to the other digital pin.
 Whereas, the pin number has to be changed in 3 different statements in version-2.
 The magic happens when you click the upload icon in the Arduino IDE. The program
will be uploaded into the microcontroller of Arduino board and LED in the circuit
starts blinking.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 4
Aim: Using Arduino Uno implement the Fade-in and fade-out the LED experiment.
Overview: In the process of experimenting with Arduino, writing the Arduino program is not
the only important thing, building the breadboard circuit is equally important.
 Let’s take a look at how the breadboard circuit has to be built for both the
experiments.
 Components required:
 Arduino UNO R3 -1
 Breadboard -1
 Breadboard connectors -3
 LED -1
 1K resistor -1
Fade-in and Fade-out LED
 Steps in building a breadboard connection:
 Step-1: Connect the Arduino to the Windows / Mac / Linux system via a
USB cable
 Step-2: Connect the 9th digital pin of Arduino to the positive power rail of
the breadboard and GND to the negative
 Step-3: Connect the positive power rail to the terminal strip via a 1K ohm
resistor
 Step-4: Fix the LED to the ports below the resistor connection in the
terminal strip
 Step-5: Close the circuit by connecting the cathode (the short chord) of the
LED to the negative power strip of the breadboard

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Arduino program for LED fade-in and fade-out (Version-1)


int led = 9; // The digital pin to which the LED is connected
int brightness = 0; // Brightness of LED is initially set to 0
int fade = 5; // By how many points the LED should fade
void setup()
{
pinMode(led, OUTPUT); //pin 10 is set as output pin
}
void loop() // The loop function runs again and again
{
analogWrite(led, brightness); // set the brightness of LED
brightness = brightness + fade; //Increase the brightness of LED by 5 points
if (brightness <= 0 || brightness >= 255) // check the level of brightness
{
fade = -fade;
}
delay(30); // Wait for 30 milliseconds
}
Arduino program for LED fade-in and fade-out (Version-2)
int led=19; // The digital pin to which the LED is connected
void setup()
{
pinMode(led, OUTPUT); //pin 10 is set as output pin
}
void loop() // The loop function runs again and again
{
for (int fade=0; fade<=255; fade=fade+5)
{
analogWrite (led, fade); // Change the brightness of LED by 5 points
delay (30);
}
}

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

 In both the versions of the LED fade-in and fade-out programs, the analogWrite
statement is used for a led connected to a digital pin. The reason for this is that, digital
pin 10 is a PWM pin. 
 A PWM pin is capable of generating Analog output. In both the programs pin 10 is
used as analog output pin.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 5

Aim: Using Arduino Uno implement Array Programs.

Example 1: Declaring an Array and using a Loop to Initialize the Array’s Elements.

Overview: The program declares a 10-element integer array n. Lines a–b use a for statement
to initialize the array elements to zeros. Like other automatic variables, automatic arrays are
not implicitly initialized to zero. The first output statement (line c) displays the column
headings for the columns printed in the subsequent for statement (lines d–e), which prints the
array in tabular format.

Code:

int n[ 10 ] ; // n is an array of 10 integer

void setup ()

void loop ()

for ( int i = 0; i < 10; ++i ) // initialize elements of array n to 0

n[ i ] = 0; // set element at location i to 0

Serial.print (i);

Serial.print (‘\r’);

for ( int j = 0; j < 10; ++j ) // output each array element's value

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Serial.print (n[j]);

Serial.print (‘\r’);

Output:

Element Value

0 0

1 0

2 0

3 0

4 0

5 0

6 0

7 0

8 0

9 0

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Example: 2 Initializing an Array in a Declaration with an Initializer List.

Overview: The elements of an array can also be initialized in the array declaration by
following the array name with an equal-to sign and a brace-delimited comma-separated list of
initializers. The program uses an initializer list to initialize an integer array with 10 values
(line a) and prints the array in tabular format (lines b–c).

Code:

// n is an array of 10 integers

int n[ 10 ] = { 32, 27, 64, 18, 95, 14, 90, 70, 60, 37 }

void setup ()

void loop ()

for ( int i = 0; i < 10; ++i )

Serial.print (i);

Serial.print (‘\r’);

for ( int j = 0; j < 10; ++j ) // output each array element's value

Serial.print (n[j]);

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Serial.print (‘\r’);

Output:

Element Value

0 32

1 27

2 64

3 18

4 95

5 14

6 90

7 70

8 60

9 37

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Example 3: Summing the Elements of an Array

Overview: Often, the elements of an array represent a series of values to be used in a


calculation. For example, if the elements of an array represent exam grades, a professor may
wish to total the elements of the array and use that sum to calculate the class average for the
exam. The program sums the values contained in the 10-element integer array a.

Code:

const int arraySize = 10; // constant variable indicating size of array

int a[ arraySize ] = { 87, 68, 94, 100, 83, 78, 85, 91, 76, 87 };

int total = 0;

void setup ()

void loop ()

// sum contents of array a

for ( int i = 0; i < arraySize; ++i )

total += a[ i ];

Serial.print (“Total of array elements: ”);

Serial.print(total) ;

Output:

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Total of array elements: 849


Practical: 6
Aim: Write a program to manipulate string arrays.
Code:
void setup()
{
char str[] = "This is my string"; // create a string
char out_str[40]; // output from string functions placed here
int num; // general purpose integer
Serial.begin(9600);

// (1) print the string


Serial.println(str);

// (2) get the length of the string (excludes null terminator)


num = strlen(str);
Serial.print("String length is: ");
Serial.println(num);

// (3) get the length of the array (includes null terminator)


num = sizeof(str); // sizeof() is not a C string function
Serial.print("Size of the array: ");
Serial.println(num);

// (4) copy a string


strcpy(out_str, str);
Serial.println(out_str);

// (5) add a string to the end of a string (append)


strcat(out_str, " sketch.");
Serial.println(out_str);
num = strlen(out_str);
Serial.print("String length is: ");

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Serial.println(num);
num = sizeof(out_str);
Serial.print("Size of the array out_str[]: ");
Serial.println(num);
}
void loop()
{
}
Output:
This is my string
String length is: 17
Size of the array: 18
This is my string
This is my string sketch.
String length is: 25
Size of the array out_str[]: 40

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 7
Aim: Write a program to create a function that determines a number is even or odd.
Code:
int a= 0;
int b;
void setup()
{
Serial.begin(9600);
}
void loop()
{
b = Evenfunction(a); // we can store the function return value in variable b
Serial.print(a);
Serial.print(" : "); // to separate even or odd text
if (b==1)
{
Serial.println( " Number is even");
}
else
{
Serial.println("Number is odd");
}
a++; // the function will increment and will again run
delay(1000);
}
int Evenfunction(int d)
{
if (d% 2==0)
{
return 1;
}
else
{

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

return 0;
}
}
Output:

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 8
Aim: Write a program to implement blinking multiple LEDs using the loop.

Hardware Required:

The components required for the project are listed below:

 3 x red LED
 3 x 220 Ohm Resistors
 Arduino UNO R3 board
 Jump wires

Principle:

 We will connect the three LEDs to pins 13, 8, and 4 of the Arduino board. The
limiting value of resistance should be between 220 and 330 ohms to set the optimal
current through the LEDs.
 The required resistance is enough to light up an LED without damaging the board and
the LED. We will turn the LED ON/OFF individually.

Procedure:

The connection of the above project is discussed below:

 Connect the resistor of 220 Ohm in series with the three LEDs. Now connect it to
the pin number 13, 8, and 4 of the Arduino board.
 Connect the negative terminal of the three LEDs to the GND (Ground).

Connection Diagram:

 We will show the connection using the Simulator because the connections become
clearer and more precise.
 We can make the same connection using the hardware devices.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Code:
/*
This program blinks LED connection to the pin number 13, 8, and 4
*/
void setup()
{
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
pinMode(4, OUTPUT);
}
void loop()
{
// the first LED is made to blink one time
digitalWrite(13, HIGH);
delay(1000); // delay time in milliseconds
digitalWrite(13, LOW);
delay(1000);
// the second LED will blink two times
digitalWrite(8, HIGH);
delay(500); // the duration is 0.5 seconds
digitalWrite(8, LOW);
delay(500);
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

// the third LED will blink three times


for( int i = 0; i < 3; i = i +1 )
{
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
delay(500);
// We can adjust the delay time accordingly
}
}

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 9
Aim: Write a program to implement blinking multiple LEDs using switch case.
Hardware Required:
The components required for the project are listed below:

 4 x red LED
 4 x 220 Ohm Resistors
 Arduino UNO R3 board
 Jump wires
Principle:

 We will connect the four LEDs to pins 12, 11, 8, and 6 of the Arduino board. The
resistors of 220 Ohm are connected in series with the LEDs.

 The switch statement will compare the declared value of a variable with statements in
other cases. The code associated with the matching case will run.

 We will also change or rearrange the LEDs connected to the specified pin number on
the board.

Connection:

The connection of the above project is discussed below:

 Connect the resistor of 220 Ohm in series with the four LEDs. Now connect it to the
pin number 12, 11, 8, and 6 of the Arduino board.
 Connect the negative terminal of the five LEDs to the GND (Ground).

Connection Diagram:

 We will show the connection using the Simulator because the connections become
clearer and more precise.

 We can make the same connection using the hardware devices.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Code:
void setup()
{
// initialize serial communication:
Serial.begin(9600);
// initializing the LED pins:
for (int LEDpin = 6; LEDpin <13 ; LEDpin++)
{
pinMode(LEDpin, OUTPUT);
// here, we have used for loop for initialization
}
}
void loop()
{
int a = 3; // we can specify any variable name
switch (a)
{
case 1:
digitalWrite(6, HIGH);

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

break;
case 2:
digitalWrite(8, HIGH);
break;
case 3:
digitalWrite(11, HIGH);
break;
case 4:
digitalWrite(12, HIGH);
break;
default:
// turn all the LEDs off if all the above cases does not matches:
for (int LEDpin = 6; LEDpin <13; LEDpin++)
{
digitalWrite(LEDpin, LOW);
}
}
}
Output:
The LED connected to the PIN 11 will light up, as shown below:

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Practical: 10
Aim: Explain working of Raspberry Pi.

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

The Raspberry Pi device looks like a motherboard, with the mounted chips and ports exposed
but it has all the components you need to connect input, output, and storage devices and start
computing. Raspberry Pi uses a system-on-a-chip with all those components on a single chip. 
Here are the accessories you’ll need to get up and running:
 A power supply. Raspberry Pi doesn’t come with one, so you’ll need a micro USB
compatible cable in order to plug it into the wall. 

 A case. There’s no official one yet, so I put mine in this pink one from Adafruit.
Unfortunately, despite what you may have heard, it does not fit in an Altoids tin.

 An HDMI cable or RCA video lead. You can’t use your Pi without a visual display.
You can either plug it into a computer monitor with HDMI input using an HDMI
cable, or you can plug it into an analogue TV with a standard RCA composite video
lead.

 A USB mouse and keyboard. Or else how will you interact with the Pi? Any wired
or wireless mouse and keyboard should do; I’m using wireless Logitech products for
both. 

 An SD memory card. You’ll need one to boot up the Pi. The Raspberry Pi
foundation recommends at least 4 gigs to start, but as many as 32 if you want. 

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

 A primary computer. I didn’t get that you can’t just get the Pi running without
already owning another computer, Mac or PC. Hopefully you already have one of
these, or this project just got a lot more expensive. 

 An SD memory card reader. The Raspberry Pi doesn’t need this, but your primary
computer does so you can transfer installations from it to the Pi. A lot of computers
come with a built-in card reader, but if yours doesn’t, you might want to invest in one.

Now, let’s fast-forward to the day when your Raspberry Pi and all its accessories arrive in the
mail. Here’s what to do, and when to do it. 
 Put your Raspberry Pi in its case. Unless it’s very customized, it should continue to
have holes in it for all of the Pi’s inputs

 Put the Pi aside and go to your primary computer. Insert your SD card and format
it according to the Foundation’s directions. This will install a recovery program on it
so you can save your card even if you break it with your tinkering. 

 Download NOOBS on your primary computer. Short for New Out Of Box
Software, it’s the Raspberry Pi Foundation’s fittingly named distro for first-time Pi
users. A distro is a package installation of Linux and its associated software. 

 Load your NOOBS download onto the newly formatted SD card. 

 Time to get started with the Raspberry Pi. Slide the SD card into the underside of
the Raspberry Pi, and make sure it’s oriented correctly; it’d be bad to break your Pi
before you turn it on!

 Connect it to the power supply, monitor, keyboard, and mouse. 

 The Raspberry Pi will boot up and take you the NOOBS screen. If it doesn’t,
check your power supply and HDMI cables and make sure they’re secure.

 Select an OS to install. If you select the default Raspbian, recommended for


beginners, Adafruit has a great tutorialon the process. This install will take a while (20
minutes for me) so this is a good time to go do something else.

 Once the file copies, you’ll get a notice that says, “Image applied successfully.” Press
return, and the Pi will reboot. Now it will boot into the operating system’s graphical
user interface, which looks a lot like Windows 98. 

MGITER/CE/6th/2023 210330107507
IoT and Applications-3160716

Now you’re ready to use your Raspberry Pi however you like. You can run programs on it as
if it were any other computer, or you can choose to work from the command line. Since it’s a
general purpose Linux machine, what you do from here is up to you.

MGITER/CE/6th/2023 210330107507

You might also like