AI Orb (ESP32 + GC9A01 + WiFi) — 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 <WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_GC9A01A.h>

// --- YOUR EXACT WIRING ---
#define TFT_CS   4
#define TFT_DC   2
#define TFT_MOSI 5
#define TFT_SCLK 18
#define TFT_BL   16

Adafruit_GC9A01A tft(TFT_CS, TFT_DC);

String fakeAnswers[] = {
  "I am your AI assistant.",
  "The weather is 25C and sunny.",
  "Robotics is the future!",
  "Mainframe connected.",
  "Error: Human detected."
};
int answerIndex = 0;

void setup() {
  Serial.begin(115200);
  
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, HIGH);
  
  SPI.begin(TFT_SCLK, -1, TFT_MOSI, TFT_CS);
  
  tft.begin();
  tft.setRotation(0);
  tft.fillScreen(GC9A01A_BLACK);
  
  tft.setTextColor(GC9A01A_CYAN);
  tft.setTextSize(2);
  tft.setCursor(20, 100);
  tft.print("Connecting...");

  WiFi.begin("Velxio-GUEST", "");
  int attempts = 0;
  while (WiFi.status() != WL_CONNECTED && attempts < 10) {
    delay(500);
    attempts++;
  }
  
  tft.fillScreen(GC9A01A_BLACK);
  tft.setCursor(50, 100);
  if (WiFi.status() == WL_CONNECTED) {
    tft.print("AI Ready");
  } else {
    tft.print("No WiFi");
  }
  delay(1000);
  tft.fillScreen(GC9A01A_BLACK);
}

void loop() {
  if (Serial.available()) {
    String userQuestion = Serial.readStringUntil('\n');
    userQuestion.trim();
    
    if (userQuestion.length() > 0) {
      
      // 1. Show Thinking
      tft.fillScreen(GC9A01A_BLACK);
      tft.setTextColor(GC9A01A_WHITE);
      tft.setTextSize(2);
      tft.setCursor(40, 100);
      tft.print("Thinking");
      
      delay(1000);
      tft.print(".");
      delay(500);
      tft.print(".");
      delay(500);
      
      // 2. Show Answer
      tft.fillScreen(GC9A01A_BLACK);
      
      // Question (Small font)
      tft.setTextSize(1);
      tft.setTextColor(GC9A01A_CYAN);
      tft.setCursor(20, 30); // Moved inwards to avoid the circle edge
      tft.print("USER: ");
      tft.println(userQuestion);
      
      // Answer (Small font, but bold-looking color)
      tft.setTextColor(GC9A01A_GREEN);
      tft.setCursor(20, 70); // Moved down
      tft.print("AI: ");
      
      String answer = fakeAnswers[answerIndex];
      tft.println(answer);
      
      answerIndex++;
      if (answerIndex > 4) answerIndex = 0;
    }
  }
}

More projects by tareq-neoaz