Week2 - IoT Lab Experiments
Week2 - IoT Lab Experiments
The Positive pin(+ve) of the Arduino Buzzer has to be connected to the VCC of Arduino and the
Negative pin(-ve) has to be connected to the GND pin of the Arduino. The components required
to interface Buzzer with Arduino UNO. Arduino UNO, Buzzer, Breadboard, 100 ohms Resistor,
Connecting jumper wires.
void setup(){
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}
void loop(){
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000); // ...for 1sec
}
(ii) Buzzer with Arduino UNO - Application with Buzzer to play a Music
+ -
Light Dependent Resistor(LDR) technology is widely used in may industrial, education and
commercial applications. It is highly sensitive contactless operation allows it to replace
mechanical switches for a wide range of needs. The LDR can be found in use as light sensors or
solar radiation detectors, controlling street lights on highways, automatically changing the
direction of traffic signals at intersections. Even photoelectric equipment such as smoke detector
alarms all rely upon this small but efficient device which monitors changes from darkness into
ambient light with impressive accuracy.
LDR is Light Dependent Register. LDR is for sensing light. If intensity of light is more then its
intensity decreases. If intensity of light is dark then its intensity increases.
Program:
x = digitalRead(7);
Serial.println(x); //print data to serial port
if(x == HIGH)
{
digitalWrite(13, HIGH); //LED=blink HIGH
}
if(x == LOW)
{
digitalWrite(13, LOW); //LED=blink LOW
}
}
Output: 0 = shows LED OFF when focus light on LDR
1 = shows LED ON when no focus light on LDR
EXPERIMENT-6
6. Write program for IR Sensor using Arduino UNO.
IR sensor is an electronic device, that emits the light in order to sense some object of the
surroundings. An IR sensor can measure the heat of an object as well as detects the motion.
Usually, in the infrared spectrum, all the objects radiate some form of thermal radiation.
These types of radiations are invisible to our eyes, but infrared sensor can detect these
radiations.
Application of IR sensor
Water analysis
Petroleum exploration
Rail safety
Gas detectors
Program:
int LED = 13; // LED in 13 pin for HIGH=blink
int x = 7; //IR sensor value stored in x variable
int y;
void setup()
{
// put your setup code here, to run once:
pinMode(LED, OUTPUT); //pin 7 for LDR = OUTPUT
pinMode(x, INPUT); //PIN 13 LED for blink=HIGH
}
void loop()
{
// put your main code here, to run repeatedly:
y = digitalRead(x);
if (y == LOW)
digitalWrite(LED, HIGH); //LED=blink HIGH
else
digitalWrite(LED, LOW); //LED=blink LOW
}
***