0% found this document useful (0 votes)
94 views8 pages

Master of Computer Application: 2nd Year, Semester-3

This document summarizes 5 IoT projects completed by a student for their M.C.A program. The projects include: 1. An ultrasonic sensor to measure distance. 2. A circuit with 3 LED lights blinking on and off sequentially. 3. An LDR sensor to control an LED based on light levels. 4. A PIR sensor to detect motion and turn on an LED. 5. A gas sensor to detect gas levels and control 4 LEDs as indicators.
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)
94 views8 pages

Master of Computer Application: 2nd Year, Semester-3

This document summarizes 5 IoT projects completed by a student for their M.C.A program. The projects include: 1. An ultrasonic sensor to measure distance. 2. A circuit with 3 LED lights blinking on and off sequentially. 3. An LDR sensor to control an LED based on light levels. 4. A PIR sensor to detect motion and turn on an LED. 5. A gas sensor to detect gas levels and control 4 LEDs as indicators.
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/ 8

Sarvajanik College of Engineering & Technology, Surat

Gujarat Technological University - Ahmadabad

Master of Computer Application

2nd Year, Semester-3

Journal Submitted by
(SHUBHAM D. PATEL - 205310694015)

Under the Guidance Of


(Prof. ZankhanaVaishnav)
(Prof. Dr. Kaushika Pal)

Internet of Things - 639409


Index

Sr. No Program Date Sign


1 Ultrasonic Sensor

2 3 Led Lights

3 LDR Sensor

4 PIR Sensor

5 Gas Sensor
Ultrasonic Sensor
Code:
#define tri_pin 12
#define echo_pin 11

int duration,distance;

void setup()
{
  Serial.begin(9600);
  pinMode(tri_pin, OUTPUT);
  pinMode(echo_pin, INPUT);
 
}

void loop()
{
  digitalWrite(tri_pin, LOW);
  delay(1000);
  digitalWrite(tri_pin, HIGH);
  delay(1000);
  digitalWrite(tri_pin, LOW);
  duration=pulseIn(echo_pin,HIGH);
  distance=duration*0.034/2;
  Serial.println(duration);
  Serial.println(distance);
  delay(1000);
}

Output:
3 Led Lights
Code:
void setup(){
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}
void loop(){
  digitalWrite(13, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(13, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(12, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(12, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(11, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(11, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
 
  digitalWrite(11, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(11, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(12, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(12, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(13, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(13, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
}

Output:
LDR Sensor
Code:
const int ledPin = 9;
const int ldrPin = A0;

void setup()
{
Serial.begin(9600);
      pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
}

void loop()
{
int ldrStatus = analogRead(ldrPin);
      if (ldrStatus >=600)
      {
      analogWrite(ledPin, 200);
            Serial.println("LDR is DARK, LED is ON");
      }
      else
      {
      analogWrite(ledPin, 50);
            Serial.println("LED OFF");
      }
}

Output:
PIR Sensor
Code:
int buttonState = 0;

void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
// read the state of the pushbutton buttonState = digitalRead(2);
// check if pushbutton is pressed. if it is, the
// button state is HIGH
if (buttonState == HIGH)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else
{
digitalWrite(LED_BUILTIN, LOW);
}
delay(100);
}

Output:
Gas Sensor
Code:
int const PINO_SGAS = A1;
int LED_VERDE = 7;
int LED_AMARELO = 6;
int LED_VERMELHO1 = 5;
int LED_VERMELHO2 = 4;

void setup()
{
pinMode(LED_VERDE, OUTPUT);
pinMode(LED_AMARELO, OUTPUT);
pinMode(LED_VERMELHO1, OUTPUT);
pinMode(LED_VERMELHO2, OUTPUT);
Serial.begin(9600);
}

void loop()
{
int valor = analogRead(PINO_SGAS);
valor = map(valor, 300, 750, 0, 100);
digitalWrite(LED_VERDE, HIGH);
digitalWrite(LED_AMARELO, valor >= 30 ? HIGH : LOW);
digitalWrite(LED_VERMELHO1, valor >= 50 ? HIGH : LOW);
digitalWrite(LED_VERMELHO2, valor >= 80 ? HIGH : LOW);
delay(250);
}

Output:

You might also like