How to interface Ultrasonic sensor with Arduino UNO (Arduino Series - Part 05)
Display the results from the HC-SR04 Ultrasonic Sensor on an LCD Display Hardware Required: - Arduino Board - Ultrasonic Sensor HC-SR04 - LCD Display - 1k ohm resistor - Breadboard and wires Ultrasonic Sensor HC-SR04 Connections: - The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. - The HC-SR04 sensor attach to the Breadboard - The Sensor VCC connect to the Arduino Board +5V - The Sensor GND connect to the Arduino Board GND - The Sensor Trig connect to the Arduino Board Digital I/O 10 - The Sensor Echo connect to the Arduino Board Digital I/O 11 Look the basic tutorial about the HC-SR04 https://youtu.be/OFlt5vgCzZs LCD Display Connection: Before wiring the LCD screen to your Arduino or Genuino board ...
Count is fluctuating between 1 and 0 initially.
ReplyDeleteyes, i also faced the same pblm
Delete
Delete#include
LiquidCrystal lcd(12,11,5,4,3,2);
#define in 8
#define out 9
#define relay 10
int count=0;
void IN()
{
count++;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void OUT()
{
count--;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void setup()
{
lcd.begin(16,2);
lcd.print("Visitor Counter");
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(relay, OUTPUT);
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
}
void loop()
{
if(digitalRead(in)){
IN();}
if(digitalRead(out)){
OUT();}
if(count<=0)
{
lcd.clear();
digitalWrite(relay, LOW);
lcd.clear();
lcd.print("Nobody In Room");
lcd.setCursor(0,1);
lcd.print("Light Is Off");
delay(200);
}
else
digitalWrite(relay, HIGH);
}
Hey!
ReplyDeleteWhat is the total approximate cost of this project
I'm thinking of making it for my college
Maximum Rs. 1000 to Rs. 1500
DeleteWhich resistor is used
ReplyDeleteYes
Delete1k resistor
DeleteGood job bro
ReplyDeleteGood Job, thanks for sharing code
ReplyDeletethis is correct code
Delete#include
LiquidCrystal lcd(12,11,5,4,3,2);
#define in 8
#define out 9
#define relay 10
int count=0;
void IN()
{
count++;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void OUT()
{
count--;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void setup()
{
lcd.begin(16,2);
lcd.print("Visitor Counter");
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(relay, OUTPUT);
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
}
void loop()
{
if(digitalRead(in)){
IN();}
if(digitalRead(out)){
OUT();}
if(count<=0)
{
lcd.clear();
digitalWrite(relay, LOW);
lcd.clear();
lcd.print("Nobody In Room");
lcd.setCursor(0,1);
lcd.print("Light Is Off");
delay(200);
}
else
digitalWrite(relay, HIGH);
}
ReplyDelete#include
LiquidCrystal lcd(12,11,5,4,3,2);
#define in 8
#define out 9
#define relay 10
int count=0;
void IN()
{
count++;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void OUT()
{
count--;
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
delay(1000);
}
void setup()
{
lcd.begin(16,2);
lcd.print("Visitor Counter");
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(relay, OUTPUT);
lcd.clear();
lcd.print("Person In Room:");
lcd.setCursor(0,1);
lcd.print(count);
}
void loop()
{
if(digitalRead(in)){
IN();}
if(digitalRead(out)){
OUT();}
if(count<=0)
{
lcd.clear();
digitalWrite(relay, LOW);
lcd.clear();
lcd.print("Nobody In Room");
lcd.setCursor(0,1);
lcd.print("Light Is Off");
delay(200);
}
else
digitalWrite(relay, HIGH);
}
Bro here we are useing fan not light with relay and pin layout is also different
ReplyDeleteCode wrong hai ☺️ please help me
ReplyDelete