Assignment - 02: Experiment: 11

You might also like

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

Internet Of Things

Assignment - 02

Name - Param Shah

Roll No - 1741019

Experiment : 11: -

(a) ​Measure values of different resistors:

(b) ​Take a variable resistor (Potentiometer). Measure the values of


resistance with help of multi-meter for three different positions of
the potentiometer settings.
(c) Measure different values of LDR for different light intensities​ .

Less/0 Light: 4.97 V


Medium Light Intensity: 2.14 V
Full Light Intensity: 1.68 V

Observe how resistance changes with light intensity

Less/0 Light: 180 kΩ


Medium Light Intensity: 1.3K Ω
Full Light Intensity: 506 Ω

Value of resistance decreases with increasing intensity of light.


(d)​ ​How do you measure Short-Circuit with help of Multi-meter?

(1)Checking continuity by connecting to probes of multimeter (some of


them even make sound to notify.
(2) If resistance is 0 that can also be checked .

(e) Take a push-button switch. Use multi-meter to determine that,


when you press the switch, which legs of the switch are
connected.When the switch is not pressed, which legs are
connected? Draw the circuit of the switch representing its
connections.

When push button is pressed whole circuit is connected with no open end .
When the push button is not pressed, two legs on both sides are
connected. But both the sides have no connection.
Exp:12
Exp:13

1.Connect LDR in series with one Resistor.

2. Connect one end to +5 V from Arduino andother end to Ground Pin of Arduino.

3. Measure voltage across LDR for different Light intensities on LDR.

4. Switch the positions of LDR and Resistor Repeat point 3 on this configuration.
Exp:14

Change Blinking rate of LED using potentiometer

Code:

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
Explain analogRead(): ​

This Function is used for reading values from analog pins i.e from A0-A5
where devices keep their input .

Potentiometers have part which can vary its resistance to control that part
we have knob , wiper is the contact part to the external pin . resistance
varies as per the knob if meter shows away from the end terminal it is
greater .
Exp -15 :

Changing intensity using potentiometer

Code

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {

sensorValue = analogRead(sensorPin);
analogWrite(ledPin, sensorvalue/4);

}
Exp-16:

Code:

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}

Case - 1
Case -2

When the light falls on the LDR, then the electrons in the valence band of the material
are eager to the conduction band. When the effect of this process and the flow of the
current starts flowing more, the resistance of the device decreases.

Equation :

V​ in​ = V​ out​ ×(R1 + R2)/R2


Exp - 17 :

Code -

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
analogWrite(ledPin,sensorValue);
}
Case - 1

Case - 2
Exp:18

Code:

int A = 13;
int B = 12;
int C = 11;
int D = 10;
int E = 9;
int F = 8;
int G = 7;
int H = 6;

void setup(void)
{
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(H, OUTPUT);
}

//My Functions

void zerofunc(void) {
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void onefunc(void) {
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void twofunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
digitalWrite(H, LOW);
}

void threefunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void fourfunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void fivefunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void sixfunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void sevenfunc(void) {
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void eightfunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

void ninefunc(void) {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(D, HIGH);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
digitalWrite(H, LOW);
}

// Start
void loop(void)
{
zerofunc();
delay(1000);

onefunc();
delay(1000);

twofunc();
delay(1000);

threefunc();
delay(1000);

fourfunc();
delay(1000);

fivefunc();
delay(1000);

sixfunc();
delay(1000);

seven();
delay(1000);

eightfunc();
delay(1000);

ninefunc();
delay(1000);

ninefunc();
delay(1000);

eightfunc();
delay(1000);

sevenfunc();
delay(1000);
sixfunc();
delay(1000);
fivefunc();
delay(1000);

fourfunc();
delay(1000);

threefunc();
delay(1000);

twofunc();
delay(1000);

onefunc();
delay(1000);

zerofunc();
delay(1000);

Exp_19 :
Explain:
○ Serial.begin(9600): ​ This function is mainly used to set bit rate for serial
transfer.
○ Serial.println(..): ​ This function is used to print data in serial monitor so that
human can understand .

Code:

/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
Exp-20:

Code:
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the Serial Monitor
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode
(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead
(pushButton);
// print out the state of the button:
Serial.println
(buttonState);
delay(1); // delay in between reads for stability }
Thank You

You might also like