Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd (13, 12, 11, 10, 9, 8);
- #define in 3
- #define out 4
- #define relay 2
- int count = 0;
- void IN()
- {
- count++;
- lcd.clear();
- lcd.print("Person In Bus:");
- lcd.setCursor(0, 1);
- lcd.print(count);
- delay(1000);
- }
- void OUT()
- {
- count--;
- lcd.clear();
- lcd.print("Person(s)in Bus:");
- lcd.setCursor(0, 1);
- lcd.print(count);
- delay(1000);
- }
- void setup()
- {
- lcd.begin(16, 2);
- lcd.print("The Smart Station");
- delay(2000);
- pinMode(in, INPUT);
- pinMode(out, INPUT);
- pinMode(relay, OUTPUT);
- lcd.clear();
- lcd.print("Person(s)in Bus:");
- 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 Bus");
- lcd.setCursor(0, 1);
- delay(200);
- }
- else
- digitalWrite(relay, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement