FPT (Vending Machine)
FPT (Vending Machine)
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
byte rowPins[ROWS] = { 9, 8, 7, 6 };
byte colPins[COLS] = { 5, 4, 3, 2 };
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
}
void setup() {
lcd.init(); // Initialize the LCD screen
lcd.backlight();
lcd.clear(); // Clear the LCD screen
Serial.begin(9600); // Set the serial baud rate
}
void loop() {
//Loop for when the code is empty so that the function runs over again
if (code == "") {
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
if (customKey) {
Serial.println(customKey);
lcd.setCursor(0, 1);
lcd.print(code);
}
}
if (code == "9") {
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
// Clear the screen after 3 seconds
delay(3000);
clear();
delay(3000);
code = "";
}
if (code == "C") {
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
delay(2000);
clear();
// Set the output and then print it
outputString1 = "Pay by pressing";
outputString2 = "the button";
lcd.setCursor(0, 0);
lcd.print(outputString1);
lcd.setCursor(0, 1);
lcd.print(outputString2);
delay(3000);
code = "";
}
}