প্রজেক্টটি করতে যা যা লাগবেঃ

Sl: No:

Required Items Quantity (pcs) Product Link

01.

Arduino UNO

01

Click here

02.

Bread Board

01

Click here

03.

One Channel 5V Relay

01

Click here

04.

Ultrasonic Sonar Sensor (HC-SR-04)

01

Click here

05.

Male to Male Jumper wires As required Click here

06.

Male to Female jumper wires As required Click here

07.

2 Pin Plug + Wire 01 + As required
08. Bulb 01

09.

Bulb Holder 01

 

 

সার্কিট কানেকশনঃ

One Channel

5V Relay

Arduino UNO
VCC 5V
GND GND
In Digital pin 2

 

Ultrasonic Sonar Sensor Arduino UNO
VCC 5V
GND GND
Trig Digital pin 12
Echo Digital pin 13

 

Other Connections
Relay (NO)

[Normally Open]

Bulb (+ve)
Plug (+) Relay (COM)

[Common]

Plug (-) Bulb (-ve)

 

সার্কিট ডায়াগ্রামঃ

 

আরডুইনো কোডঃ


/* Presented by: https://sigmatechbd.com/


* Prepared by: M.A.Hasnat


*/


const int trigPin = 12;


const int echoPin = 13;

long duration;
int distance;

void setup() {
pinMode (2,OUTPUT);
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);
digitalWrite(trigPin,HIGH);

distance = duration*0.034/2;

Serial.print("Distance: ");
Serial.println(distance);

if (distance <=20)
{
digitalWrite(2,HIGH);
delay(500);
}
else
{
digitalWrite(2,LOW);
delay(500);
}
}