cofffe shop — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by tareq-neoaz.

Components

Sketch code

#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>

// Custom Colors
#define CUSTOM_BROWN 0x8200 

// --- SCREEN 1 (CUSTOMER) ---
#define TFT1_CS 15
#define TFT1_DC 2
#define TFT1_RST 4
Adafruit_ILI9341 tft1 = Adafruit_ILI9341(TFT1_CS, TFT1_DC, TFT1_RST);

// --- SCREEN 2 (BARISTA) ---
#define TFT2_CS 13
#define TFT2_DC 12
#define TFT2_RST 14
Adafruit_ILI9341 tft2 = Adafruit_ILI9341(TFT2_CS, TFT2_DC, TFT2_RST);

// --- CUSTOMER BUTTONS ---
#define BTN_HOTCHOC 25
#define BTN_ESPRESSO 26
#define BTN_LATTE 27
#define BTN_CAPPUCCINO 32
#define BTN_MOCHA 33

// --- BARISTA BUTTONS ---
#define BTN_GRINDING 16
#define BTN_BREWING 17
#define BTN_MILK 5
#define BTN_DONE 19 

// --- BUZZER & LED ---
#define PIN_BUZZER 21
#define PIN_LED 22

String currentOrder = "None";
String currentStatus = "Idle";
String baristaAction = "Idle";

int orderFinished = 0; 
unsigned long lastTouchTime = 0;
bool lastTouchState = LOW;
unsigned long animTimer = 0;
int animFrame = 0;
bool needsRedraw = true;

unsigned long readyTimer = 0;
bool isDisplayingReady = false;

void setup() {
  Serial.begin(115200);
  
  pinMode(BTN_HOTCHOC, INPUT_PULLUP);
  pinMode(BTN_ESPRESSO, INPUT_PULLUP);
  pinMode(BTN_LATTE, INPUT_PULLUP);
  pinMode(BTN_CAPPUCCINO, INPUT_PULLUP);
  pinMode(BTN_MOCHA, INPUT_PULLUP);
  
  pinMode(BTN_GRINDING, INPUT_PULLUP);
  pinMode(BTN_BREWING, INPUT_PULLUP);
  pinMode(BTN_MILK, INPUT_PULLUP);
  pinMode(BTN_DONE, INPUT); 
  
  pinMode(PIN_BUZZER, OUTPUT);
  pinMode(PIN_LED, OUTPUT);
  
  tft1.begin();
  tft1.setRotation(4);
  tft1.fillScreen(ILI9341_BLACK);
  tft1.setTextSize(2);
  
  tft2.begin();
  tft2.setRotation(4);
  tft2.fillScreen(ILI9341_BLACK);
  tft2.setTextSize(2);
  
  updateScreens();
}

void loop() {
  bool touchState = digitalRead(BTN_DONE);
  if (touchState == HIGH && lastTouchState == LOW) {
    if (millis() - lastTouchTime > 500) { 
      if (orderFinished == 0) {
        currentStatus = "READY!"; 
        baristaAction = "READY!"; 
        orderFinished = 1; 
        readyTimer = millis(); 
        isDisplayingReady = true;
      } else {
        currentOrder = "None";
        currentStatus = "Idle";
        baristaAction = "Idle";
        orderFinished = 0; 
        isDisplayingReady = false;
      }
      needsRedraw = true;
      lastTouchTime = millis();
    }
  }
  lastTouchState = touchState;

  if (isDisplayingReady && (millis() - readyTimer > 5000)) {
    currentOrder = "None";
    currentStatus = "Idle";
    baristaAction = "Idle";
    orderFinished = 0;
    isDisplayingReady = false;
    needsRedraw = true;
  }

  if (millis() - lastTouchTime > 500) {
    if (digitalRead(BTN_HOTCHOC) == LOW) { currentOrder = "Hot Cocoa"; baristaAction = "New Order!"; orderFinished = 0; isDisplayingReady = false; needsRedraw = true; beepAndFlash(); lastTouchTime = millis(); }
    if (digitalRead(BTN_ESPRESSO) == LOW) { currentOrder = "Espresso"; baristaAction = "New Order!"; orderFinished = 0; isDisplayingReady = false; needsRe

More projects by tareq-neoaz