Objective :
to learn ultrasonic sensor and programing for automatic LED on-off
INTRODUCTION:
Ultrasonic Sensor:
- An ultrasonic sensor is an electronic device that measures the distance of target object by emitting ultrasonic sound wave and convert the reflected sound into an electrical signal
- Ultrasonic wave travelled faster than the audible sound that’s why human ear can not able hear this sound.
- Range of Ultrasonic Wave – 40 to 70 kHz range.
- Frequency range of audible sound – above 20 Hz to 20 kHz.
Task 03: Automatic LED ON/ OFF using Ultrasonic Sensor
Task to ON/OFF LED using Ultrasonic Sensor
Equipment’s:
- Arduino UNO(1)
- Ultrasonic Sensor (HC-SC04)
- Bread Board(1)
- LED (1)
- Resistor 220 ohm (1)
- Jumping Wires
Software Used:
- Arduino Uno
- Tinker CAD
Connection:
Sketch :
#define trigPin 13
#define echoPin 12
#define led 11
void setup()
{ Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{ long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 10)
{ digitalWrite(led,HIGH);
}
else {
digitalWrite(led,LOW);
}
Serial.print(distance);
Serial.println(” cm”);
delay(500);
}
After the Completing this Task, I Work on Implementation of Automatic Light ON/OFF System.
Refer the link given below for implementation:
Application:
Automatic Light ON/OFF system can be used to:
- Lift light
- kitchen light
- Bathroom light
- Dark Rooms ,etc.