1#include <LiquidCrystal.h>
2LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
3int visitors = 0;
4int sensor = 6;
5int sensor1 = 7;
6int buzzer = 8;
7
8
9void setup() {
10 lcd.begin(16, 2);
11 lcd.print("Visitor counter");
12 lcd.setCursor(0, 1);
13 lcd.print("Visitors:");
14 lcd.setCursor(9,2);
15 lcd.print(visitors);
16}
17
18void loop() {
19int sensorstate = digitalRead(sensor);
20int sensor1state = digitalRead(sensor1);
21
22 if(sensorstate == HIGH){
23 digitalWrite(buzzer,HIGH);
24 visitors++;
25 delay(1500);
26 }
27
28 else if (sensor1state == HIGH) {
29 visitors--;
30 delay(1500);
31 digitalWrite(buzzer,LOW);
32 }
33 lcd.setCursor(9,2);
34 lcd.print(visitors);
35}
36
37
38
Anonymous user
4 years ago
Very nice! Can you explain how to assemble the components? Thank you!