Make a touchless Doorbell | Using arduino uno with ultrasonic sensor | Plugin Electronics
ฝัง
- เผยแพร่เมื่อ 18 มี.ค. 2024
- Material Required:
Arduino Uno
Jumper wires
buzzer
Ultrasonic sensor
Breadboard
Arduino Uno cable
Power Bank or 9v Battery
----------------------------------------------
Subscribe : )
---------------------------------------------- - วิทยาศาสตร์และเทคโนโลยี
Code:
const int trigPin = 4;
const int echoPin = 5;
const int buzzerPin = 8;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
int duration = pulseIn(echoPin, HIGH);
delay(50);
int distance = duration / 29.1;
if (distance < 20) {
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
}
}
thank u soo much sir!!!!!! this worked for me on the very first try. please upload other projects like this. thank you once again !!!!!!
Welcome
New video will upload soon : )
Bro ur cheat
Its not working
Its play automatically within 5 sec