/* ----------------------------------------------------
AI Queue Assistant (Proof of Concept)
Board: Raspberry Pi Pico / Pico W (Arduino core)
Components: I2C LCD 16x2, 3 LEDs, Push Button, Buzzer
---------------------------------------------------- */
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// LCD at I2C address 0x27
LiquidCrystal_I2C lcd(0x27, 16, 2);
// ----- Pin Mapping -----
#define BUTTON_PIN 15
#define LED_GREEN 16
#define LED_YELLOW 17
#define LED_RED 18
#define BUZZER 19
// ----- Variables -----
int tokenNumber = 1;
int estimatedWait = 5; // minutes per token
bool lastButtonState = LOW;
// ----- Helper Functions -----
void buzzerBeep(int times = 1) {
for (int i = 0; i < times; i++) {
digitalWrite(BUZZER, HIGH);
delay(200);
digitalWrite(BUZZER, LOW);
delay(200);
}
}
void showMessage(const char *line1, const char *line2 = "") {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(line1);
lcd.setCursor(0, 1);
lcd.print(line2);
}
void setLEDs(bool r, bool y, bool g) {
digitalWrite(LED_RED, r);
digitalWrite(LED_YELLOW, y);
digitalWrite(LED_GREEN, g);
}
// ----- Setup -----
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLDOWN);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_YELLOW, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(BUZZER, OUTPUT);
lcd.init();
lcd.backlight();
setLEDs(HIGH, LOW, LOW);
showMessage("Queue Assistant", "Initializing...");
delay(2000);
setLEDs(LOW, HIGH, LOW); // Waiting state
}
// ----- Loop -----
void loop() {
bool buttonState = digitalRead(BUTTON_PIN);
// Display current queue state
showMessage(
(String("Token: T-") + String(tokenNumber)).c_str(),
(String("ETA: ") + String(estimatedWait) + " min").c_str()
);
if (buttonState == HIGH && lastButtonState == LOW) {
// Button pressed — move to serving state
setLEDs(LOW, LOW, HIGH);
showMessage("Now Serving", (String("T-") + String(tokenNumber)).c_str());
buzzerBeep(2);
delay(2000);
// Move to next token
tokenNumber++;
estimatedWait = 5;
// Simulate processing
setLEDs(HIGH, LOW, LOW);
showMessage("Processing...", "");
delay(1000);
setLEDs(LOW, HIGH, LOW); // Back to waiting
}
lastButtonState = buttonState;
delay(100); // debounce
}