Final Lab Report

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

IoT (CS-201)

S. No. Lab Experiment Date Signature


1 Write the code to blink an LED on Arduino MKR1000. Compile and verify the
result on the serial monitor of Arduino IDE.
2 Interfacing of Arduino MKR1000 with LED and switch. Write a program to
control LED using Switch.
3 Interfacing of Arduino MKR1000 with potentiometer and LED. Write a program
to vary the intensity of LED using a potentiometer.
4 (a) Interfacing of Ultrasonic sensor with Arduino MKR1000. Write a program to
measure the distance from obstacle and display on the serial monitor.
(b) Interface an IR sensor with Arduino MKR1000. Write a program to detect
obstacle and display on the serial monitor.

5
(a) Interfacing of Temperature sensor with Arduino MKR1000. Write a program
to read the specific temperature of a room and display on the serial monitor.
(b) Interfacing of LDR with Arduino MKR1000. Write a program to control the
intensity of LED using LDR.

6 (a) Interfacing of DC motor with Arduino MKR1000. Write a program to rotate


the motor in clockwise and anticlockwise direction with using a delay of 2 sec.
(b) Familiarize the concept of pulse width modulation. Write a program to
control the speed of DC motor using PWM.

7 (a) Interfacing of a display device, i.e., LCD x2 with Arduino MKR1000. Write a
program to display “HELLO IOT” on LCD.
(b) Write a program to scroll the message “Welcome to IoT Lab.”
(c) Write a program to blink the message “Hello IoT.”

8 Write down the steps to connect Arduino MKR1000 with IoT cloud. Write a
program to blink an LED using Arduino IoT cloud.
9
Write a program to visualize data of temperature sensor on Arduino IoT cloud.

10 Design an interface to control the speed of DC motor using cloud services. Store
and visualize the data of speed of DC motor after every one sec.
IoT (CS-201)
EXPERIMENT 1
Aim of the Experiment: To Blink LED

Components Used: Arduino UNO, LED, Resistor, Tinkercad Simulator.

Circuit Diagram:

Figure : Blinking of LED

Software program:
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(13, HIGH);
Serial.println("LED : ON");
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
Serial.println("LED : OFF");
delay(1000); // Wait for 1000 millisecond(s)
}
IoT (CS-201)

Screenshot of Serial monitor:


IoT (CS-201)
EXPERIMENT 2
Aim of the Experiment: Controlling LED with Switch.

Components Used: Arduino UNO, LED, Resistor, Tinkercad Simulator, Switch.

Circuit Diagram:

Figure : Control of LED using Switch


Software program:
int button = 8;
void setup()
{
pinMode(13, OUTPUT);
pinMode(button, INPUT);
}
void loop()
{
int value = digitalRead(button);
if(value==HIGH)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
}
IoT (CS-201)
EXPERIMENT 3

Aim of the Experiment : Intensity of Led using Potentiometer .

Components Used : Arduino UNO,Led,Potentiometer,Resistor,Tinckercad simulator .

Circuit Diagram:

Figure : Intensity of Led using Potentiometer

Software program:
int value=0;
void setup()
{
pinMode(A0, INPUT);
pinMode(11, OUTPUT);
}
void loop()
{
value = analogRead(A0);
digitalWrite(11,HIGH);
delay(value);

digitalWrite(11, LOW);
delay(value);
}
IoT (CS-201)
EXPERIMENT 4(a)
Aim of the Experiment: Measure the distance from obstacle and display on the serial
monitor using ultrasonic sensor

Components Used: Arduino UNO, Ultrasonic sensor, Tinkercad Simulator.

Circuit Diagram:

Figure : Ultrasonic Sensor

Software program:
const int trigpin =6;
const int echopin =7;
int distance;
int duration;
void setup()
{
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
Serial.begin(9600);
}
IoT (CS-201)
void loop()
{
digitalWrite(trigpin, LOW);
delayMicroseconds(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);
distance = (0.034*duration)/2;
Serial.print("Distance is =");
Serial.println(distance);
}

Screenshot of Serial monitor:


IoT (CS-201)
EXPERIMENT 4(b)

Aim of the Experiment: To Detect Obstacle.

Components Used: Arduino UNO, IR Sensor, IR Remote, Tinkercad Simulator.

Circuit Diagram :

Figure : Setup of IR Sensor

Software program:
int ir;
void setup()
{
pinMode(11,INPUT);
Serial.begin(9600);
}
void loop()
{
ir=digitalRead(11);
Serial.println(ir);
}
IoT (CS-201)
Screenshot of Serial monitor:
IoT (CS-201)
EXPERIMENT 5(a)

Aim of the Experiment: To read the specific temperature of a room.

Components Used: Arduino UNO, Temprature Sensor, Resistor, LCD, Potentiometre,


Tinkercad Simulator.

Circuit Diagram:

Figure : Temprature Sensor

Software program:
#include <LiquidCrystal.h>

int sensePin = A0;


int sensorInput;
double temp;
LiquidCrystal lcd(12,11,5,4,3,2);
IoT (CS-201)
void setup()
{

Serial.begin(9600);
lcd.begin(16,2);
}
void loop()
{
sensorInput = analogRead(A0);
temp = (double)sensorInput / 1024;
temp = temp * 5;
temp = temp - 0.5;
temp = temp * 100;
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.setCursor(6,0);
lcd.print(temp);
Serial.print("Current Temperature: ");
Serial.println(temp);
}

Screenshot of Serial monitor:


IoT (CS-201)

EXPERIMENT 5(b)
Aim of the Experiment: Controlling the intensity of LED using LDR.

Components Used: Arduino UNO, LED, Photoresistor, Resistor,Tinkercad Simulation.

Circuit Diagram:

Figure Controlling intensity of LED using LDR


Software program:
const int ledPin = 7;
const int ldrPin = A0;
void setup()
{

Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);

void loop()
{
IoT (CS-201)
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 200)
{

digitalWrite(ledPin, HIGH);
Serial.print("Its DARK, Turn on the LED : ");
Serial.println(ldrStatus);

}
else
{

digitalWrite(ledPin, LOW);
Serial.print("Its BRIGHT, Turn off the LED : ");
Serial.println(ldrStatus);

}
}

Screenshot of Serial monitor:


IoT (CS-201)

EXPERIMENT 6(a)

Aim of the Experiment: Rotating a DC Motor in clockwise & anticlockwise direction using delay.

Components Used: Arduino UNO, DC Motor, H- Bridge Motor Driver, Tinkercad Stimulation.

Circuit Diagram:

Figure Rotating DC motor


Software program:
int In1=12;
int In2=9;
void setup()
{

pinMode(In1,OUTPUT);
pinMode(In2,OUTPUT);
Serial.begin(9600);

}
IoT (CS-201)

void loop()
{
digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);
Serial.println(“Clockwise”);
delay(2000);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
Serial.println(“Anti Clockwise”);
delay(2000);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
Serial.println(“Stop”);
delay(2000);
}

Screenshot of Serial Monitor:


IoT (CS-201)
EXPERIMENT 6(b)

Aim of the Experiment: Control the speed of DC motor using PWM.

Components Used: Arduino UNO, DC Motor, Tinkercad Simulator.

Circuit Diagram:

Figure : Rotating DC Motor

Software program:
int en=5;
int In1=12;
int In2=9;
void setup()
{

pinMode(en,OUTPUT);
pinMode(In1,OUTPUT);
pinMode(In2,OUTPUT);
Serial.begin(9600);

}
IoT (CS-201)
void loop()
{
analogWrite(en,255);
digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);
Serial.println("Clockwise");
delay(2000);
analogWrite(en,255);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
Serial.println("Anti Clockwise");
delay(2000);
analogWrite(en,255);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
Serial.println("Stop");
delay(2000);
}

Screenshot of Serial monitor:


IoT (CS-201)
EXPERIMENT 7(a)

Aim of the Experiment: Display “HELLO IOT” on LCD.

Components Used: Arduino UNO, LCD, Potentiometer, Resistor,Tinkercad Simulator.

Circuit Diagram:

Figure : Setup for Print of Hello Iot

Software program:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(4,0);
lcd.print("Hello IoT");
delay(1000);
}
IoT (CS-201)

EXPERIMENT 7(b)

Aim of the Experiment: Scroll the message “Welcome to IoT Lab”.

Components Used: Arduino UNO, Tinkercad Simulation, LCD, Potentiometer, Resistor.

Circuit Diagram:

Figure Setup for Scrolling.


Software program:
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{ lcd.begin(16, 2);
lcd.print("hello, world!");
delay(1000); }
void loop()
{ for (int positionCounter = 0; positionCounter < 13; positionCounter++)
{ lcd.scrollDisplayLeft();
delay(150); }
for (int positionCounter = 0; positionCounter < 16; positionCounter++)
{ lcd.scrollDisplayLeft();
delay(150); }
}

3
IoT (CS-201)

EXPERIMENT 7(c)

Aim of the Experiment: Blinking the message “Hello IoT”.

Components Used: Arduino UNO, Tinkercad Simulation, LCD, Resistor, Potentiometer.

Circuit Diagram:

Figure Setup for Blinking


Software program:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{ lcd.begin(16, 2); }
void loop()
{
lcd.setCursor(4,0);
lcd.print("Hello IoT");
delay(1000);
lcd.clear();
delay(500);
}

You might also like