Materials:-
- Arduino uno = https://bit.ly/30v5XcY
- Ultrasonic sensor = https://bit.ly/2ZbwH1V
- LCD display = http://bit.ly/37SLuRJ
Diagram:-
Connections:-
LCD display to arduino
- Vss = Arduino GND
- VDD = Arduino 5V
- V0 = Potentiometer center pin
- RS = Digital pin 3
- RW = Arduino GND
- E = Digital pin 4
- D4 = Arduino digital pin 5
- D5 = Arduino digital pin 6
- D6 = Arduino digital pin 7
- D7 = Arduino digital pin 8
- A = Arduino 5V
- K = Arduino GND
Potentiometer to arduino
- Left pin = Arduino GND
- Right pin = Arduino 5v
- center pin = Display VO
Ultrasonic sensor to arduino
- Sensor VCC = Arduino 5V
- Sensor GND = Arduino GND
- Sensor Trig = Arduino D10
- Sensoe Echo = arduino D9
Downloads:-
- LCD display library(LiquidCrystal.h) = http://bit.ly/2VeF5xt
- Code = https://bit.ly/3i0goxN
Code#include <LiquidCrystal.h>LiquidCrystal lcd(3, 4, 5, 6, 7, 8);#define trigpin 10#define echopin 9int stats;int count = 0;void setup(){ analogWrite(2, 10);pinMode(trigpin, OUTPUT);pinMode(echopin, INPUT);Serial.begin(9600);lcd.begin(16, 2);}void loop(){int duration, distance;digitalWrite(trigpin, HIGH);delayMicroseconds(1000);digitalWrite(trigpin, LOW);duration = pulseIn(echopin, HIGH);distance = ( duration / 2) / 29.1;if (distance < 20) {stats = 1;} else {stats = 0;}if (stats == 1) {count = count + 1;}Serial.print(count);Serial.println();lcd.setCursor(0, 0 );lcd.print("Visitors counter");lcd.setCursor(0, 1 );lcd.print("Visitors: ");lcd.setCursor(10, 1 );lcd.print(count);delay(600);lcd.clear();}