0% found this document useful (0 votes)
29 views19 pages

IOT RECORD - pdf2

internet of things basic concepts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views19 pages

IOT RECORD - pdf2

internet of things basic concepts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Experiment 1

AVERAGE OF THREE NUMBERS

Aim:
Write aprogram to find the average of three numbers

Program:

a=int(input("Enter the first number: "))


b=int(input("Enter the second number:
")) c=int(input("Enter the third number:
")) avg =(a +b+c) /3 print("The average of
three numbers is:", avg)

Output:
Enter the first number:1
Enter the second
number:2 Enter the
third number:3

The average of three numbers is: 3

Result:

The above program is executed and the output is obtained


1
Experiment 2

EVEN OR NOT

Aim:
Write aprogram to check whether the given number is even or not.

Program:
num =int(input("Enter the number:"))

if num %2== 0:

print(num, "is an even number")


else: print(num, "is not an even
number")

OUTPUT:

Enter the
number:6 6is an
even number

Result:

The above program is executed and the output is obtained


2

Experiment 3

COMBINING TWO LISTS INTO ADICTIONARY USING PYTHON

Aim:

Write aprogram to combine two lists into adictionary.

Program:

t1 =["name", "place", "age"]


t2 =["mary", "kollam",
25] res ={}
for key in
t1:
for value in t2:
res[key] =value
t2.remove(value)
break print(res)

Output:

{'name': mary', 'place' :'kollam','age' :25 }

Result:

The above program is executed and the output is obtained


Experiment 4

FINDING THE BIGGEST OF THREE NUMBERS USING AFUNCTION

Aim:

Write aprogram to find the biggest of three numbers using afunction.

13
Program:

def biggest(a, b, c):


if a>b:
if a>c: return
aelse:
return celse:
if b>c: return
belse:
return c

a=int(input("Enter the first number:


")) b=int(input("Enter the second
number: ")) c=int(input("Enter the
third number: ")) big =biggest(a, b, c)
print("Big number =", big)

Output:
Enter the first number:10
Enter the second number:30
Enter the third number:20

Big number =30

Result:
The above program is executed and the output is obtained.

4
Experiment 5

DRAWING ASQUARE USING TURTLE GRAPHICS IN


PYTHON

Aim:

Write aprogram to draw asquare using turtle object..

Program:

import turtle

t=turtle.Turtle()
s=int(input("Enter the length of the square: "))

for iin range(4):


t.forward(s)
t.left(90)

turtle.done()

Output:
Enter the length of the square :200

Result:

The above program is executed and the output is obtained.

15
Experiment 6

DRAWING ARECTANGLE USING GRAPHICS IN


PYTHON

Aim:

Write aprogram to draw arectangle using turtle object..

Program:

import turtle

t=turtle.Turtle()

length =int(input("Enter the length of the rectangle: "))


breadth =int(input("Enter the breadth of the rectangle: "))
for iin range(2):
t.forward(length)
t.left(90)
t.forward(breadth)
t.left(90)

turtle.done()
Output:
Enter the length of the rectangle :500
Enter the breadth of the rectangle :200

Result:

The above program is executed and the output is obtained.

6
Experiment 7

ARDUINO BOARD FAMILIARIZATION FOR BEGINNERS


Aim: To familiarize beginners with the Arduino board, its components, and
basic functionalities.

Components:
Arduino Board (e.g., Arduino Uno)
USB Cable
Breadboard
Jumper Wires

Procedure:
1. Examine the Arduino board, identifying components such as the
microcontroller, digital and analog pins, power jack, USB port, and reset
button.
2. Connect the Arduino board to acomputer using the USB cable.
3. Open the Arduino IDE on the computer.
4. Write asimple code to blink an LED connected to pin 13.
5. Upload the code to the Arduino board.
6. Observe the onboard LED (connected to pin 13) and external LED (if
used): Onboard LED and external LED (if used) blinking on and off.

Output: LEDs blinking on and off.

Result: The experiment successfully introduces beginners to the physical


components of the Arduino board, establishes aconnection with the computer,
and demonstrates the basic functionality of programming the board to control an
LE

17
Experiment 8

BLINKING ONE LED EXPERIMENT

Aim: Demonstrate basic control of an LED using Arduino by blinking it on and


off.

Components:
Arduino Board
LED (Light Emitting Diode)
Resistor (220-330 ohms)
Jumper Wires

Procedure:
1. Connect the anode (+) of the LED to adigital pin on the Arduino through
acurrent-limiting resistor.
2. Connect the cathode (-) of the LED to the ground (GND) on the Arduino.
3. Upload the following Arduino code to the board.
4. Observe the LED blinking on and off.

Arduino Code:

void setup()
{ pinMode(LED_BUILTIN, OUTPUT); // Set the LED pin as an
output
}
void loop()
{ digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
delay(1000); // Wait for 1second
digitalWrite(LED_BUILTIN, LOW); // Turn off the LED delay(1000);
// Wait for 1second
}
Output:

8
The LED connected to the specified pin will blink on and off at 1-second
intervals.
Result:
Successful implementation of abasic Arduino program to blink one led.
Experiment 9

SIMULATING ATRAFFIC LIGHT WITH THREE LEDS USING ARDUINO


Aim:
To create asimple traffic light simulation using three LEDs connected to an
Arduino, where each LED represents adifferent signal phase (red, yellow,
green).

Components:
Arduino board
3LEDs (Red, Yellow, Green)
3current-limiting resistors
Breadboard
Jumper wires

Procedure:
1. Connect the LEDs to the Arduino board with appropriate current-
limiting resistors.
2. Write an Arduino program to control the LEDs, simulating the traffic
light sequence (red, red-yellow, green, yellow, repeat).
3. Upload the program to the Arduino using the Arduino IDE.
4. Power the Arduino board.

Arduino Code:
int red =9;
int yellow
=8; int green
=7; void
setup()
{ pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);

9
pinMode(green, OUTPUT);
}
void loop()
{ digitalWrite(red,
HIGH) delay(15000);
digitalWrite(red,
LOW);
digitalWrite(yellow,
HIGH); delay(1000);
digitalWrite(yellow,
LOW); delay(500);

digitalWrite(green, HIGH);
delay(20000);
digitalWrite(green, LOW);
delay(500);

Output:

The LEDs will display asimulated traffic light sequence, cycling through the
phases of red, red-yellow, and green, with appropriate delays to mimic atypical
traffic light.

Result:

Upon successful execution, the Arduino-controlled LEDs will replicate the


behavior of a traffic light, providing avisual simulation of the standard traffic
signal sequence.

10
Experiment 10

OBSTACLE DETECTION SYSTEM USING IR SENSOR

Aim:
To design asimple Arduino experiment utilizing an IR sensor to detect
obstacles and provide avisual output.

Components:
Arduino Uno
IR Sensor Module
Jumper Wires
Breadboard
LEDs (Red and Green)
Resistors (220 ohms)
Power Supply (9V)
Procedure:
1. Connect the IR Sensor VCC to Arduino 5V, GND to GND, and Signal to
Arduino digital pin 2.
2. Connect the Red LED's anode to Arduino digital pin 3through a220-ohm
resistor and cathode to GND.
3. Connect the Green LED's anode to Arduino digital pin 4through a220-ohm
resistor and cathode to GND.
4. Power the Arduino Uno using the 9V power supply.
5. Write acode to read IR sensor data and control the LEDs accordingly. (See
code below)
6. Upload the code to the Arduino using the Arduino IDE.
7. Observe the LEDs:
Red LED ON indicates obstacle detection.
Green LED ON indicates no obstacle.

Code:

int irSensorPin =2;


int redLedPin =3;
int greenLedPin
=4;
11
void setup()
{ pinMode(irSensorPin, INPUT);
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin,
OUTPUT);
Serial.begin(9600);
}

void loop()
{
int obstacle =digitalRead(irSensorPin);

if (obstacle == HIGH)
{ digitalWrite(redLedPin, HIGH);
digitalWrite(greenLedPin,
LOW);
Serial.println("Obstacle detected!");
}
else
{ digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin,
HIGH);
Serial.println("No obstacle detected.");
}

delay(500);
}

Output: Visual indication using LEDs (Red LED for obstacle detected, Green LED
for no obstacle).

Result: The experiment successfully demonstrates the use of an IR sensor to


detect obstacles, providing avisual indication through LEDs based on sensor
readings.

12
Experiment 11

MOTION DETECTION SYSTEM USING PIR


SENSOR

Aim: To create an Arduino experiment utilizing aPIR sensor for detecting motion
and triggering aresponse.

Components:
Arduino Uno
PIR (Passive Infrared) Sensor Module
Jumper Wires
LEDs (any color)
Resistors (220 ohms)
Breadboard
Power Supply (9V)

Procedure:

1. Connect PIR Sensor VCC to Arduino 5V, GND to GND, and OUT to Arduino
digital pin 2.

2. Connect the anode of the LED to Arduino digital pin 3through a220-ohm
resistor and the cathode to GND.

3. Power the Arduino Uno using the 9V power supply.

4. Write acode to read PIR sensor data and control the LED when motion is
detected. (See code below)

5. Upload the code to the Arduino using the Arduino IDE.

6. Observe the LED:


a. LED ON indicates motion detection.
Code:

int pirSensorPin =2;


int ledPin =3;

13
void setup()
{ pinMode(pirSensorPin,
INPUT); pinMode(ledPin,
OUTPUT); Serial.begin(9600);
}
void loop()
{ int motion
=digitalRead(pirSensorPin);

if (motion == HIGH)
{ digitalWrite(ledPin,
HIGH);
Serial.println("Motion detected!");
}
else
{ digitalWrite(ledPin,
LOW);
Serial.println("No motion detected.");
}

delay(500);
}

Output: Visual indication using an LED (LED ON for motion detected).

Result: The experiment successfully demonstrates the use of aPIR sensor for
motion detection, triggering an LED response based on sensor readings
Experiment 12

GAS DETECTION SYSTEM USING ARDUINO AND MQ-7 SENSOR

Aim: To design an Arduino experiment using an MQ-7 gas sensor for detecting
and displaying the concentration of combustible gases.

Components:
Arduino Uno
MQ-7 Gas Sensor Module

14
Jumper Wires
Breadboard
Power Supply (9V)

Procedure:
1. Connect the MQ-7 sensor VCC to Arduino 5V, GND to GND, Analog OUT to
Arduino analog pin A0, and Digital OUT to Arduino digital pin 2.

2. Power the Arduino Uno using the 9V power supply.

3. Write acode to read MQ-7 sensor data, detect gas presence, and display it
on the serial monitor. (See code below)

4. Upload the code to the Arduino using the Arduino IDE.

5. Observe the serial monitor.


Real-time display of gas concentration.
Code:
const int mq7AnalogPin =A0;
const int mq7DigitalPin =2;

void setup()
{ pinMode(mq7DigitalPi
n,
INPUT); Serial.begin(9600);
}

void loop()
{ int gasConcentration
=analogRead(mq7AnalogPin); int gasPresence
=digitalRead(mq7DigitalPin);

Serial.print("Gas Level: ");


Serial.print(gasConcentration);
Serial.println(" ppm");

if (gasPresence == HIGH)
{
Serial.println("Gas Detected!");
}

15
delay(1000);
}
Output: Real-time gas concentration displayed on the LCD; "Gas Detected!"
message on Serial Monitor if gas is present.

Result: The experiment successfully demonstrates the use of an MQ-7 gas


sensor with
Arduino for real-time gas concentration monitoring and gas presence detection
Experiment 13

FAMILIARIZATION OF RASPBERRY PI

Aim: To familiarize Raspberry pi 4model B.

Procedure:

Raspberry Pi is asmall single board computer. By connecting peripherals like


Keyboard, mouse, display to the Raspberry Pi, it will act as amini personal
computer. Raspberry Pi is popularly used for real time Image/Video Processing,
IoT based applications and Robotics applications. Raspberry Pi Foundation
officially provides Debian based Raspbian OS. Also, they provide NOOBS OS for
Raspberry Pi. We can install several Third-Party versions of OS like Ubuntu,
Archlinux, RISC OS, Windows 10 IOT Core, etc.

Raspberry Pi processor :
It has ARM based Broadcom Processor SoC along with on-chip GPU (Graphics
Processing Unit).The CPU speed of Raspberry Pi varies from 700 MHz to 1.2 GHz.
Also, it has on-board SDRAM that ranges from 256 MB to 1GB. Raspberry Pi also
provides on-chip SPI, I2C, I2S and UART modules.

PIN DIAGRAM:

16
ARaspberry Pi 4board has 40 pins on it. Among these pins, we have four power
pins on the Raspberry Pi, two of which are 5v pins and another two are 3.3v pins.
The 5v power pins are connected directly to the Raspberry Pi's power input and
we can use these pins to run low power applications

5V pins: The 5V pins are used to output the 5V power supply provided by
the Type-C port. The pins are numbered 2and 4on the Raspberry Pi
4device.

3.3V pins: The 3.3V pins provide a3.3V power supply to the external
components, numbered 1and 17.

Ground pins: The ground pins are used to close the electric circuits. The
ground pins help you to protect your board from burning and play an
important part in a circuit. The ground pins are numbered
6,9,14,20,25,30,34 and 39.

Reserved Pins: These pins are used to perform communication between


I2C and
EEPROM. If you are new to Raspberry Pi, you are advised not to connect
anything with these pins, which are 27 and 28 number pins. That leaves
us with 28 GPIO pins, labeled starting from GPIO 0and going up to GPIO
27.

Result:To familiarized Raspberry pi .


Experiment 14

17
IR SENSOR CONTROL USING RASPBERRY PI WITH PYTHON APPLICATION

Aim: To design an experiment using aRaspberry Pi to control an IR sensor


through a Python application.

Components:
Raspberry Pi (any model with GPIO pins)
IR Sensor Module
Jumper Wires

Procedure:
1. Connect the IR Sensor's VCC to 5V, GND to GND, and Signal to aGPIO pin
(e.g., GPIO17) on the Raspberry Pi.

2. Install the required Python libraries (e.g., RPi.GPIO).

3. Write aPython script to read data from the IR sensor and control an output
(e.g., GPIO18).

4. Run the Python script to execute the program.

5. Observe the output (e.g., an LED connected to GPIO18):


LED turning ON when the IR sensor detects an object and OFF when
no object is detected.

Python code :

import RPi.GPIO as
GPIO import time
GPIO.setmode(GPIO.BCM)
ir_sensor_pin =17
led_pin =18

GPIO.setup(ir_sensor_pin, GPIO.IN)
GPIO.setup(led_pin, GPIO.OUT)

try:

18
while True:
if GPIO.input(ir_sensor_pin) == GPIO.HIGH:
print("Object detected!") GPIO.output(led_pin, GPIO.HIGH)
else:
print("No object detected.")
GPIO.output(led_pin, GPIO.LOW)
time.sleep(1)

except
KeyboardInterrupt:
GPIO.cleanup()

Output: Console messages indicating object detection status and LED turning
ON/OFF accordingly.

Result: The experiment successfully demonstrates Raspberry Pi interfacing with an


IR sensor through aPython application, providing real-time feedback on object
detection and controlling an output, such as an LED.

19

You might also like