IoT Lab 8-11: Controlling Intensity of Led using Potentiometer, Traffic Control System, Interfacing of Ultrasonic sensor, IR sensor, Temperature, LDR

Experiment 8 

Aim: To demonstrate Control of Led Intensity using Potentiometer 

Components required: 

LEDs

Breadboard

Arduino Uno

Potentiometer

Register

Jumper wires


Connection Diagram:




Code:

int value=0; 

void setup()

{

pinMode(A0, INPUT); 

pinMode(13, OUTPUT);

}

void loop()

{

value = analogRead(A0); 

digitalWrite(13,HIGH); 

 delay(value);

digitalWrite(13, LOW); 

  delay(value);

}

Result:




Successfully demonstrated Control of Led Intensity using Potentiometer 

Experiment 8a

Aim: To demonstrate Adjust the brightness of LED without using potentiometer

Components required:

LED 
Register
Aurduino
Breadboard
jumper wire

Connection diagram:


Code: 

int value=0; 
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
  for(int fad=0;fad<256;fad+=5)
  {
     analogWrite(13,fad);
     delay(100);
  }
    
}

Result:


Lab 9: Arduino program to implement traffic control system

Aim: To demonstrate implementation of traffic control system using Arduino

Components required:

Arduino Uno

LEDs (2 Red, 2 Green, 1 Yellow)

Breadboard

Jumper wires

Pushbutton

Registers

Connection/Circuit diagram:


pinMode(carRed, OUTPUT);

pinMode(carYellow, OUTPUT);

pinMode(carGreen, OUTPUT);

pinMode(pedRed, OUTPUT);

pinMode(pedGreen, OUTPUT);

pinMode(button, INPUT); // button on pin 2

// turn on the green light

digitalWrite(carGreen, HIGH);

digitalWrite(pedRed, HIGH);

}

void loop()

{

int state = digitalRead(button);

/* check if button is pressed and it is

over 5 seconds since last button press */

if (state == HIGH && (millis() - changeTime) > 5000)

{

  // Call the function to change the lights

changeLights();

}

}


void changeLights() {

  

digitalWrite(carGreen, LOW); // green off

digitalWrite(carYellow, HIGH); // yellow on

delay(2000); // wait 2 seconds

digitalWrite(carYellow, LOW); // yellow off

digitalWrite(carRed, HIGH); // red on

delay(1000); // wait 1 second till its safe

digitalWrite(pedRed, LOW); // ped red off

digitalWrite(pedGreen, HIGH); // ped green on

delay(crossTime); // wait for preset time period

// flash the ped green

for (int x=0; x<10; x++) {

digitalWrite(pedGreen, HIGH);

  delay(250);

digitalWrite(pedGreen, LOW);

delay(250);

}

// turn ped red on

digitalWrite(pedRed, HIGH);

delay(500);

digitalWrite(carYellow, HIGH); // Yellow will switch on

digitalWrite(carRed, LOW); // red will switch off

delay(1000);

digitalWrite(carGreen, HIGH);

digitalWrite(carYellow, LOW); // Yellow will switch off

// record the time since last change of lights

changeTime = millis();

  // Retun / Loop

}

Result:

Successfully demonstrated traffic control system using Arduino

 Experiment 10: Interfacing of Ultrasonic sensor with Arduino 

Aim: To measure the distance from obstacle and display on the serial monitor using ultrasonic sensor.

Components required:

Ultrasonic sensor

breadboard

jumper wires

Arduino uno

Connection Diagram:

Code:

const int trigpin =5; 

const int echopin =4; 

int distance;

int duration; 

void setup()

{

   pinMode(trigpin, OUTPUT);

   pinMode(echopin, INPUT); 

   Serial.begin(9600);

}

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);

}


Result:

Distance is = 102

Experiment 10(b): Interfacing an IR sensor with Arduino Uno


Aim: Program to detect obstacle and display on the serial monitor.

Components required: Arduino, breadboard, IR sensor, IR remote

Connection Diagram:

Code:

int ir;

void setup()

{

 pinMode(7,INPUT);

 Serial.begin(9600);

}

void loop()

{

ir=digitalRead(7); 

    Serial.println(ir);



}

Result:

Lab 11 (a): Interfacing of Temperature sensor with Arduino Uno


Aim: Program to read the specific temperature of a room and display on the serial monitor.

Components required: Temperature sensor, Arduino, Breadboard, Jumper wires, LCD, register

Connection diagram:

Code:


#include <LiquidCrystal.h>


int sensePin = A0; int sensorInput; double temp;

LiquidCrystal lcd(12,11,5,4,3,2);

 

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);

}


Result:

Exp 11b: Interfacing of LDR with Arduino Uno


Aim: Program to control the intensity of LED using LDR.

Components required: Arduino, LDR sensor, register, breadboard, LED, jumper wires

Connection diagram:

Code:

const int ledPin = 10; 

const int ldrPin = A0; 

void setup()

{

  Serial.begin(9600); 

  pinMode(ledPin, OUTPUT); 

  pinMode(ldrPin, INPUT);

}


void loop()

{

 int ldrStatus = analogRead(ldrPin); 

if (ldrStatus <= 200)

{

digitalWrite(ledPin, HIGH);

Serial.print("Its DARK, Turn on the LED : ");

Serial.println(ldrStatus);

delay(10000);

}

else

{

digitalWrite(ledPin, LOW);

Serial.print("Its BRIGHT, Turn off the LED : "); 

Serial.println(ldrStatus);

}

}

Result:

Comments

Popular posts from this blog

MICROCONTROLLER AND EMBEDDED SYSTEMS LABORATORY Part A

DBMS Lab 15-16: Design and implementation of COMPANY database. Design and implementation of MOVIE DATABASE.