Professional Documents
Culture Documents
Practical-7
Components:
1 Arduino Uno R3
1 IR Obstacle Sensor
Diagram:
Connection:
● The VCC pin of the IR sensor is connected to the 5V of the Arduino board.
● The GND pin of the IR sensor is connected to the GND of the Arduino board.
● The OUT pin(signal pin) of the IR sensor is connected to the 2 of the Arduino
board.
36
Amisha damor 21171341006
Code:
const int IN_A0 = A1; // analog input
const int IN_D0 = 5; // digital input
void setup() {
Serial.begin(9600);
pinMode (IN_A0, INPUT);
pinMode (IN_D0, INPUT);
}
int value_A0;
bool value_D0;
void loop( ) {
value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance
sensor value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance
sensor Serial.print(" Analogue = ");
Serial.print(value_A0);
Serial.print("\t Digital =");
Serial.println(value_D0);
delay(100);
}
37
Amisha damor 21171341006
Components:
1 Arduino Uno R3
1 IR Flame Sensor
Diagram:
Connection:
● The VCC pin of the IR sensor is connected to the 5V of the Arduino board.
● The GND pin of the IR sensor is connected to the GND of the Arduino board.
● The OUT pin(signal pin) of the IR sensor is connected to the 2 of the Arduino
board.
38
Amisha damor 21171341006
Code:
const int IN_A0 = A1; // analog input
const int IN_D0 = 5; // digital input
void setup() {
Serial.begin(9600);
pinMode (IN_A0, INPUT);
pinMode (IN_D0, INPUT);
}
int value_A0;
bool value_D0;
void loop( ) {
value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance
sensor value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance
sensor Serial.print(" Analogue = ");
Serial.print(value_A0);
Serial.print("\t Digital =");
Serial.println(value_D0);
delay(100);
}
39
Amisha damor 211713410
7.3)Write a program for IR E18-D80NK Sensor
Components:
1 Arduino Uno R3
1 IR E18-D80NK Sensor
Diagram:
Connection:
● The VCC pin of the IR sensor is connected to the 5V of the Arduino board.
● The GND pin of the IR sensor is connected to the GND of the Arduino board.
● The OUT pin(signal pin) of the IR sensor is connected to the 2 of the Arduino
board.
40
Amisha damor 21171341006
Code:
const int IN_A0 = A1; // analog input
const int IN_D0 = 5; // digital input
void setup() {
Serial.begin(9600);
pinMode (IN_A0, INPUT);
pinMode (IN_D0, INPUT);
}
int value_A0;
bool value_D0;
void loop( ) {
value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance
sensor value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance
sensor Serial.print(" Analogue = ");
Serial.print(value_A0);
Serial.print("\t Digital =");
Serial.println(value_D0);
delay(100);
}
41
Amisha damor 21171341006
Components:
1 Arduino Uno R3
1 IR Speed Sensor
Diagram:
Connection:
● The VCC pin of the IR sensor is connected to the 5V of the Arduino board.
● The GND pin of the IR sensor is connected to the GND of the Arduino board.
● The OUT pin(signal pin) of the IR sensor is connected to the 2 of the Arduino
board.
42
Vivek 21171341006
Code:
const int IN_A0 = A1; // analog input
const int IN_D0 = 5; // digital input
void setup() {
Serial.begin(9600);
pinMode (IN_A0, INPUT);
pinMode (IN_D0, INPUT);
}
int value_A0;
bool value_D0;
void loop( ) {
value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance
sensor value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance
sensor Serial.print(" Analogue = ");
Serial.print(value_A0);
Serial.print("\t Digital =");
Serial.println(value_D0);
delay(100);
}
43
Vivek Durga 211713410
Practical-8
Components:
1 Arduino Uno R3
1 UltraSonic Sensor (HE SR04)
Diagram:
Connection:
● The VCC pin of the UltraSonic sensor is connected to the 5V of the Arduino board.
● The GND pin of the UltraSonic sensor is connected to the GND of the
Arduino board.
44
Vivek Durga 21171341006
Code:
int inches = 0;
int cm = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
// measure the ping time in cm
cm = 0.01723 * readUltrasonicDistance(7, 7);
// convert to inches by dividing by 2.54
inches = (cm / 2.54);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.println("cm");
delay(100); // Wait for 100 millisecond(s)
}
45