#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP32Servo.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
Servo servo1; // D2
Servo servo2; // D13
#define boton1 14
#define boton2 5
int button_press;
byte customChar1[] = {
B00000,
B11011,
B11011,
B00000,
B10001,
B01110,
B00000,
B00000
};
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
// pinMode(coin_pin, INPUT);
pinMode(boton1, INPUT_PULLUP);
pinMode(boton2, INPUT_PULLUP);
servo1.attach(2);
servo1.write(92);
servo2.attach(13);
servo2.write(92);
}
void loop() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Welcome To Sanitary");
lcd.setCursor(1, 1);
lcd.print("Pad Vending Machine");
lcd.setCursor(1, 3);
lcd.print(" Press The Button");
while (true) {
if (digitalRead(boton1) == LOW) {
button_press = 1;
break;
}
if (digitalRead(boton2) == LOW) {
button_press = 2;
break;
}
// if (digitalRead(boton3) == LOW) {
// button_press = 3;
// break;
// }
// if (digitalRead(boton4) == LOW) {
// button_press = 4;
// break;
// }
}
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Delivering... ");
lcd.setCursor(4, 2);
lcd.print("Please Wait ");
switch (button_press) {
case 1:
servo1.write(112);
delay(1000);
servo1.write(92);
delay(1000);
break;
case 2:
servo2.write(112);
delay(1000);
servo2.write(92);
delay(1000);
break;
}
lcd.clear();
lcd.setCursor(3, 1);
lcd.print("Pick Your Pad");
delay(2000);
lcd.clear();
lcd.setCursor(5, 1);
lcd.print("Thank You");
delay(100);
lcd.setCursor(5, 2);
lcd.print(" Bye");
delay(3000);
}