This code cannot br work!

#include <USBHostGiga.h>
#include <main.h>
#include <usb_host.h>
#include <usbh_cdc.h>
#include <usbh_conf.h>
#include <usbh_core.h>
#include <usbh_ctlreq.h>
#include <usbh_def.h>
#include <usbh_hid.h>
#include <usbh_hid_keybd.h>
#include <usbh_hid_mouse.h>
#include <usbh_hid_parser.h>
#include <usbh_hid_usage.h>
#include <usbh_ioreq.h>
#include <usbh_pipes.h>
#include <usbh_platform.h>

#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <WiFiNINA.h>     // Use WiFi.h for STM32 (GIGA R1)
#include <KeyboardController.h>

// ST7735 LCD Pins
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TFT_MOSI 15
#define TFT_SCLK 13

// Create LCD object
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// USB Keyboard
USBHostGiga usbHost;
KeyboardController keyboard(usbHost);

// WiFi credentials
String ssid = "";
String password = "";
bool enteringSSID = true;
bool enteringPassword = false;
bool wifiConnected = false;

// Browser input
String url = "";
bool enteringURL = false;
bool redraw = true;

// Keyboard Event
void keyPressed() {
  char key = keyboard.getKey();
  if (key >= 32 && key <= 126) {  // Printable characters
    if (enteringSSID) {
      handleSSIDInput(key);
    } else if (enteringPassword) {
      handlePasswordInput(key);
    } else if (enteringURL) {
      handleURLInput(key);
    }
    redraw = true;
  } else if (key == 13) {  // Enter key
    if (enteringSSID) {
      enteringSSID = false;
      enteringPassword = true;
      redraw = true;
    } else if (enteringPassword) {
      enteringPassword = false;
      connectToWiFi();
    } else if (enteringURL) {
      enteringURL = false;
      fetchPage(url);
    }
  } else if (key == 8) {  // Backspace
    if (enteringSSID && ssid.length() > 0) {
      ssid.remove(ssid.length() - 1);
      redraw = true;
    } else if (enteringPassword && password.length() > 0) {
      password.remove(password.length() - 1);
      redraw = true;
    } else if (enteringURL && url.length() > 0) {
      url.remove(url.length() - 1);
      redraw = true;
    }
  }
}

// Handle SSID Input
void handleSSIDInput(char key) {
  ssid += key;
}

// Handle Password Input
void handlePasswordInput(char key) {
  password += key;
}

// Handle URL Input
void handleURLInput(char key) {
  url += key;
}

// Connect to WiFi
void connectToWiFi() {
  tft.fillScreen(ST7735_BLACK);
  tft.setCursor(0, 10);
  tft.print("Connecting to WiFi...");

  WiFi.begin(ssid.c_str(), password.c_str());
  int attempts = 0;
  while (WiFi.status() != WL_CONNECTED && attempts < 10) {
    delay(1000);
    tft.print(".");
    attempts++;
  }

  if (WiFi.status() == WL_CONNECTED) {
    wifiConnected = true;
    enteringURL = true;
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("WiFi Connected!");
    delay(2000);
    redraw = true;
  } else {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("WiFi Failed!");
    delay(2000);
    enteringSSID = true;  // Restart WiFi input
    redraw = true;
  }
}

// Fetch Web Page
void fetchPage(String url) {
  tft.fillScreen(ST7735_BLACK);
  tft.setCursor(0, 10);
  tft.print("Fetching: ");
  tft.print(url);

  WiFiClient client;
  String host = url;
  String path = "/";

  int slashIndex = url.indexOf('/');
  if (slashIndex != -1) {
    host = url.substring(0, slashIndex);
    path = url.substring(slashIndex);
  }
  if (client.connect(host.c_str(), 80)) {
    client.println("GET " + path + " HTTP/1.1");
    client.println("Host: " + host);
    client.println("Connection: close");
    client.println();
  }

  String response = "";
  while (client.available()) {
    response += client.readString();
  }

  client.stop();

  tft.fillScreen(ST7735_BLACK);
  tft.setCursor(0, 10);
  tft.print("Page Loaded!");
  Serial.println(response);  // Debug print
  redraw = true;
}

void setup() {
  Serial.begin(115200);

  // Initialize display
  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST7735_BLACK);
  tft.setTextColor(ST7735_WHITE);
  tft.setTextSize(1);

  // Initialize USB host (check GIGA R1 support)
  usbHost.begin();

  tft.setCursor(0, 10);
  tft.print("Enter WiFi SSID:");
}

void loop() {
  usbHost.Task();  // Check USB keyboard
  if (redraw) {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);

    if (enteringSSID) {
      tft.print("SSID: " + ssid);
    } else if (enteringPassword) {
      tft.print("Password: ");
      for (int i = 0; i < password.length(); i++) {
        tft.print("*");
      }
    } else if (enteringURL) {
      tft.print("URL: " + url);
    }

    redraw = false;
  }
}

error massage
WARNING: library USBHost claims to run on sam architecture(s) and may be incompatible with your current board which runs on mbed_giga architecture(s).
In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hid.h:108:0: warning: "HID_ITEM_TYPE_MAIN" redefined
#define HID_ITEM_TYPE_MAIN 0

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid_keybd.h:29:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/USBHostGiga.h:7,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:1:
c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid.h:63:0: note: this is the location of the previous definition
#define HID_ITEM_TYPE_MAIN 0x00U

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hid.h:109:0: warning: "HID_ITEM_TYPE_GLOBAL" redefined
#define HID_ITEM_TYPE_GLOBAL 1

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid_keybd.h:29:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/USBHostGiga.h:7,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:1:
c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid.h:64:0: note: this is the location of the previous definition
#define HID_ITEM_TYPE_GLOBAL 0x01U

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hid.h:110:0: warning: "HID_ITEM_TYPE_LOCAL" redefined
#define HID_ITEM_TYPE_LOCAL 2

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid_keybd.h:29:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/USBHostGiga.h:7,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:1:
c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid.h:65:0: note: this is the location of the previous definition
#define HID_ITEM_TYPE_LOCAL 0x02U

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:24:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hid.h:111:0: warning: "HID_ITEM_TYPE_RESERVED" redefined
#define HID_ITEM_TYPE_RESERVED 3

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid_keybd.h:29:0,
from c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/USBHostGiga.h:7,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:1:
c:\Users\Nelson\Documents\Arduino\libraries\USBHostGiga-master/usbh_hid.h:66:0: note: this is the location of the previous definition
#define HID_ITEM_TYPE_RESERVED 0x03U

In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22:0,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*)':
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:62: error: 'UOTGHS_HSTPIPCFG_PTYPE_INTRPT' was not declared in this scope
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:93: error: 'UOTGHS_HSTPIPCFG_PTOKEN_IN' was not declared in this scope
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);
^~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:151: error: 'UOTGHS_HSTPIPCFG_PBK_1_BANK' was not declared in this scope
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:10: error: there are no arguments to 'UHD_Pipe_Alloc' that depend on a template parameter, so a declaration of 'UHD_Pipe_Alloc' must be available [-fpermissive]
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);
^~~~~~~~~~~~~~
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:10: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual uint32_t HIDBoot<BOOT_PROTOCOL>::Release()':
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:2: error: there are no arguments to 'UHD_Pipe_Free' that depend on a template parameter, so a declaration of 'UHD_Pipe_Free' must be available [-fpermissive]
UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum);
^~~~~~~~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: At global scope:
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:34:1: error: 'USBHostGiga' does not name a type; did you mean 'USBHost'?
USBHostGiga usbHost;
^~~~~~~~~~~
USBHost
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:35:29: error: 'usbHost' was not declared in this scope
KeyboardController keyboard(usbHost);
^~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:35:29: note: suggested alternative: 'USBHost'
KeyboardController keyboard(usbHost);
^~~~~~~
USBHost
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: In function 'void setup()':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:181:3: error: 'usbHost' was not declared in this scope
usbHost.begin();
^~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:181:3: note: suggested alternative: 'USBHost'
usbHost.begin();
^~~~~~~
USBHost
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: In function 'void loop()':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:188:3: error: 'usbHost' was not declared in this scope
usbHost.Task(); // Check USB keyboard
^~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:188:3: note: suggested alternative: 'USBHost'
usbHost.Task(); // Check USB keyboard
^~~~~~~
USBHost
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:197:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < password.length(); i++) {
^~~~~~~~~~~~~~~~~
In file included from c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22:0,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:21:
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'uint32_t HIDBoot<BOOT_PROTOCOL>::Release() [with unsigned char BOOT_PROTOCOL = 1; uint32_t = long unsigned int]':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:206:1: required from here
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:15: error: 'UHD_Pipe_Free' was not declared in this scope
UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum);

c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 1; uint32_t = long unsigned int]':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:206:1:   required from here
c:\Users\Nelson\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:178: error: 'UHD_Pipe_Alloc' was not declared in this scope
 pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK);
                                                                                                                                                                                ^
Multiple libraries were found for "Adafruit_ST7735.h"
Used: C:\Users\Nelson\Documents\Arduino\libraries\Adafruit-ST7735-Library-master
Not used: C:\Users\Nelson\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library
exit status 1

Compilation error: 'USBHostGiga' does not name a type; did you mean 'USBHost'?

Says it all for me

but I don't know

It means that the library probably won't work with your Arduino because it has the wrong processor chip on it

now i use this code

#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <WiFiNINA.h>
#include <USBHostGiga.h> // Use USBHostGiga library for Arduino Giga

// ST7735 LCD Pins
#define TFT_CS   10
#define TFT_RST  9
#define TFT_DC   8
#define TFT_MOSI 15
#define TFT_SCLK 13

// Create LCD object
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// Create USB Host and Keyboard Controller objects
USBHostGiga usb;
KeyboardController keyboard(usb);

// UI States
enum UIState { ENTER_SSID, ENTER_PASSWORD, ENTER_URL, SHOW_CONTENT };
UIState currentState = ENTER_SSID;

// Input and Data
String ssid = "";
String password = "";
String url = "";
String webpageContent = "";
bool redraw = true;

// Handle Keyboard Input
void handleKeyboardInput() {
    if (keyboard.available()) {
        char key = keyboard.read();
        if (key >= 32 && key <= 126) {  // Printable ASCII characters
            switch (currentState) {
                case ENTER_SSID: ssid += key; break;
                case ENTER_PASSWORD: password += key; break;
                case ENTER_URL: url += key; break;
                default: break;
            }
            redraw = true;
        } else if (key == '\n' || key == '\r') {  // Enter key
            switch (currentState) {
                case ENTER_SSID:
                    currentState = ENTER_PASSWORD;
                    Serial.println("\nEnter Password:");
                    break;
                case ENTER_PASSWORD:
                    connectToWiFi();
                    break;
                case ENTER_URL:
                    fetchPage(url);
                    break;
                default: break;
            }
            redraw = true;
        } else if (key == 8 || key == 127) {  // Backspace or Delete
            switch (currentState) {
                case ENTER_SSID:
                    if (ssid.length() > 0) ssid.remove(ssid.length() - 1);
                    break;
                case ENTER_PASSWORD:
                    if (password.length() > 0) password.remove(password.length() - 1);
                    break;
                case ENTER_URL:
                    if (url.length() > 0) url.remove(url.length() - 1);
                    break;
                default: break;
            }
            redraw = true;
        }
    }
}

// Connect to WiFi
void connectToWiFi() {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("Connecting...");
    Serial.println("\nConnecting to WiFi...");

    WiFi.begin(ssid.c_str(), password.c_str());
    int attempts = 0;
    while (WiFi.status() != WL_CONNECTED && attempts < 10) {
        delay(1000);
        tft.print(".");
        Serial.print(".");
        attempts++;
    }

    if (WiFi.status() == WL_CONNECTED) {
        currentState = ENTER_URL;
        tft.fillScreen(ST7735_BLACK);
        tft.setCursor(0, 10);
        tft.print("Connected!");
        Serial.println("\nWiFi Connected! Enter URL:");
        delay(2000);
    } else {
        currentState = ENTER_SSID;
        tft.fillScreen(ST7735_BLACK);
        tft.setCursor(0, 10);
        tft.print("Failed!");
        Serial.println("\nWiFi Failed! Enter SSID again:");
        delay(2000);
    }
    redraw = true;
}

// Fetch Web Page
void fetchPage(String url) {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("Fetching: ");
    tft.print(url);
    Serial.println("\nFetching: " + url);

    WiFiClient client;
    String host = url;
    String path = "/";

    int slashIndex = url.indexOf('/');
    if (slashIndex != -1) {
        host = url.substring(0, slashIndex);
        path = url.substring(slashIndex);
    }
    if (client.connect(host.c_str(), 80)) {
        client.println("GET " + path + " HTTP/1.1");
        client.println("Host: " + host);
        client.println("Connection: close");
        client.println();
    }

    webpageContent = "";
    while (client.available()) {
        webpageContent += client.readString();
    }
    client.stop();

    currentState = SHOW_CONTENT;
    redraw = true;
}

// Draw UI
void drawUI() {
    tft.fillScreen(ST7735_BLACK);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(1);

    switch (currentState) {
        case ENTER_SSID:
            tft.setCursor(0, 10);
            tft.print("WiFi SSID:");
            tft.setCursor(0, 20);
            tft.print(ssid);
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case ENTER_PASSWORD:
            tft.setCursor(0, 10);
            tft.print("Password:");
            tft.setCursor(0, 20);
            for (size_t i = 0; i < password.length(); i++) {
                tft.print("*");
            }
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case ENTER_URL:
            tft.setCursor(0, 10);
            tft.print("Enter URL:");
            tft.setCursor(0, 20);
            tft.print(url);
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case SHOW_CONTENT:
            tft.setCursor(0, 0);
            int yPos = 0;
            int lineNum = 0;
            for (size_t i = 0; i < webpageContent.length() && lineNum < 16; i++) {
                tft.print(webpageContent[i]);
                if (webpageContent[i] == '\n' || tft.getCursorX() >= tft.width()) {
                    yPos += 10;
                    tft.setCursor(0, yPos);
                    lineNum++;
                }
            }
            tft.setCursor(0, tft.height() - 10);
            tft.print("Press Enter to browse again");
            break;
    }
}

void setup() {
    Serial.begin(115200);
    while (!Serial);  // Wait for Serial Monitor
    tft.initR(INITR_BLACKTAB);
    tft.fillScreen(ST7735_BLACK);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(1);

    // Initialize USB Host
    if (usb.begin()) {
        Serial.println("USB Host initialized. Enter WiFi SSID:");
    } else {
        Serial.println("USB Host initialization failed!");
    }
}

void loop() {
    usb.Task(); // Process USB events
    handleKeyboardInput();
    if (redraw) {
        drawUI();
        redraw = false;
    }
    // Allow returning to URL input from content view
    if (currentState == SHOW_CONTENT && keyboard.available()) {
        char key = keyboard.read();
        if (key == '\n' || key == '\r') {
            currentState = ENTER_URL;
            url = "";
            webpageContent = "";
            redraw = true;
            Serial.println("\nEnter new URL:");
        }
    }
}

and this

#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <WiFiNINA.h>
#include <Arduino_USBHostMbed5.h> // Correct header for USB Host on Giga

// ST7735 LCD Pins
#define TFT_CS   10
#define TFT_RST  9
#define TFT_DC   8
#define TFT_MOSI 15
#define TFT_SCLK 13

// Create LCD object
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// Use the global USBHost object provided by the library
USBHost& usb = USBHost::getHost();

// Create a USB HID Keyboard object
USBHIDKeyboard keyboard;

// UI States
enum UIState { ENTER_SSID, ENTER_PASSWORD, ENTER_URL, SHOW_CONTENT };
UIState currentState = ENTER_SSID;

// Input and Data
String ssid = "";
String password = "";
String url = "";
String webpageContent = "";
bool redraw = true;

// Handle Keyboard Input
void handleKeyboardInput() {
    if (keyboard.available()) {
        char key = keyboard.read();
        if (key >= 32 && key <= 126) {  // Printable ASCII characters
            switch (currentState) {
                case ENTER_SSID: ssid += key; break;
                case ENTER_PASSWORD: password += key; break;
                case ENTER_URL: url += key; break;
                default: break;
            }
            redraw = true;
        } else if (key == '\n' || key == '\r') {  // Enter key
            switch (currentState) {
                case ENTER_SSID:
                    currentState = ENTER_PASSWORD;
                    Serial.println("\nEnter Password:");
                    break;
                case ENTER_PASSWORD:
                    connectToWiFi();
                    break;
                case ENTER_URL:
                    fetchPage(url);
                    break;
                default: break;
            }
            redraw = true;
        } else if (key == 8 || key == 127) {  // Backspace or Delete
            switch (currentState) {
                case ENTER_SSID:
                    if (ssid.length() > 0) ssid.remove(ssid.length() - 1);
                    break;
                case ENTER_PASSWORD:
                    if (password.length() > 0) password.remove(password.length() - 1);
                    break;
                case ENTER_URL:
                    if (url.length() > 0) url.remove(url.length() - 1);
                    break;
                default: break;
            }
            redraw = true;
        }
    }
}

// Connect to WiFi
void connectToWiFi() {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("Connecting...");
    Serial.println("\nConnecting to WiFi...");

    WiFi.begin(ssid.c_str(), password.c_str());
    int attempts = 0;
    while (WiFi.status() != WL_CONNECTED && attempts < 10) {
        delay(1000);
        tft.print(".");
        Serial.print(".");
        attempts++;
    }

    if (WiFi.status() == WL_CONNECTED) {
        currentState = ENTER_URL;
        tft.fillScreen(ST7735_BLACK);
        tft.setCursor(0, 10);
        tft.print("Connected!");
        Serial.println("\nWiFi Connected! Enter URL:");
        delay(2000);
    } else {
        currentState = ENTER_SSID;
        tft.fillScreen(ST7735_BLACK);
        tft.setCursor(0, 10);
        tft.print("Failed!");
        Serial.println("\nWiFi Failed! Enter SSID again:");
        delay(2000);
    }
    redraw = true;
}

// Fetch Web Page
void fetchPage(String url) {
    tft.fillScreen(ST7735_BLACK);
    tft.setCursor(0, 10);
    tft.print("Fetching: ");
    tft.print(url);
    Serial.println("\nFetching: " + url);

    WiFiClient client;
    String host = url;
    String path = "/";

    int slashIndex = url.indexOf('/');
    if (slashIndex != -1) {
        host = url.substring(0, slashIndex);
        path = url.substring(slashIndex);
    }
    if (client.connect(host.c_str(), 80)) {
        client.println("GET " + path + " HTTP/1.1");
        client.println("Host: " + host);
        client.println("Connection: close");
        client.println();
    }

    webpageContent = "";
    while (client.available()) {
        webpageContent += client.readString();
    }
    client.stop();

    currentState = SHOW_CONTENT;
    redraw = true;
}

// Draw UI
void drawUI() {
    tft.fillScreen(ST7735_BLACK);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(1);

    switch (currentState) {
        case ENTER_SSID:
            tft.setCursor(0, 10);
            tft.print("WiFi SSID:");
            tft.setCursor(0, 20);
            tft.print(ssid);
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case ENTER_PASSWORD:
            tft.setCursor(0, 10);
            tft.print("Password:");
            tft.setCursor(0, 20);
            for (size_t i = 0; i < password.length(); i++) {
                tft.print("*");
            }
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case ENTER_URL:
            tft.setCursor(0, 10);
            tft.print("Enter URL:");
            tft.setCursor(0, 20);
            tft.print(url);
            tft.drawRect(0, 18, tft.width(), 12, ST7735_YELLOW);  // Input box
            break;

        case SHOW_CONTENT:
            tft.setCursor(0, 0);
            int yPos = 0;
            int lineNum = 0;
            for (size_t i = 0; i < webpageContent.length() && lineNum < 16; i++) {
                tft.print(webpageContent[i]);
                if (webpageContent[i] == '\n' || tft.getCursorX() >= tft.width()) {
                    yPos += 10;
                    tft.setCursor(0, yPos);
                    lineNum++;
                }
            }
            tft.setCursor(0, tft.height() - 10);
            tft.print("Press Enter to browse again");
            break;
    }
}

void setup() {
    Serial.begin(115200);
    while (!Serial);  // Wait for Serial Monitor
    tft.initR(INITR_BLACKTAB);
    tft.fillScreen(ST7735_BLACK);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextSize(1);

    // Initialize USB Host
    usb.init();
    keyboard.attach(usb);

    Serial.println("USB Host initialized. Enter WiFi SSID:");
}

void loop() {
    usb.task(); // Process USB events
    handleKeyboardInput();
    if (redraw) {
        drawUI();
        redraw = false;
    }
    // Allow returning to URL input from content view
    if (currentState == SHOW_CONTENT && keyboard.available()) {
        char key = keyboard.read();
        if (key == '\n' || key == '\r') {
            currentState = ENTER_URL;
            url = "";
            webpageContent = "";
            redraw = true;
            Serial.println("\nEnter new URL:");
        }
    }
}

it can't work too

Please post any error messages that you get when compiling or uploading the code

C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:17:25: error: 'getHost' is not a member of 'USBHost'
USBHost& usb = USBHost::getHost();
^~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:20:1: error: 'USBHIDKeyboard' does not name a type
USBHIDKeyboard keyboard;
^~~~~~~~~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: In function 'void handleKeyboardInput()':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:35:9: error: 'keyboard' was not declared in this scope
if (keyboard.available()) {
^~~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: In function 'void setup()':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:206:14: error: 'void USBHALHost::init()' is protected within this context
usb.init();
^
In file included from c:\Users\Nelson\Documents\Arduino\libraries\Arduino_USBHostMbed5\src/USBHost/USBHost.h:22:0,
from c:\Users\Nelson\Documents\Arduino\libraries\Arduino_USBHostMbed5\src/USBHostMSD/USBHostMSD.h:24,
from c:\Users\Nelson\Documents\Arduino\libraries\Arduino_USBHostMbed5\src/Arduino_USBHostMbed5.h:3,
from C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:4:
c:\Users\Nelson\Documents\Arduino\libraries\Arduino_USBHostMbed5\src/USBHost/USBHALHost.h:41:10: note: declared protected here
void init();
^~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:207:5: error: 'keyboard' was not declared in this scope
keyboard.attach(usb);
^~~~~~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino: In function 'void loop()':
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:213:9: error: 'class USBHost' has no member named 'task'
usb.task(); // Process USB events
^~~~
C:\Users\Nelson\Downloads\sketch_feb26a\sketch_feb26a.ino:220:41: error: 'keyboard' was not declared in this scope
if (currentState == SHOW_CONTENT && keyboard.available()) {
^~~~~~~~

exit status 1

Compilation error: 'getHost' is not a member of 'USBHost'

It appears that the USBHost library does not have a function named getHost

Where did you get the sketch from ?

I write it,I am a rookie

and some by AI

That is not rookie code

That explains it

What does your AI friend say about the errors ?

My AI friend [GROK] say:
The errors you're encountering indicate issues with the USB keyboard implementation in your sketch. It seems you’ve modified the code to use a different USB host approach (possibly USBHost and USBHIDKeyboard from the Arduino_USBHostMbed5 library) instead of USBHostGiga.h, but the syntax and library members don’t match what’s expected. The errors suggest:

  1. 'getHost' is not a member of 'USBHost': The USBHost class doesn’t have a getHost() method in this context.

  2. 'USBHIDKeyboard' does not name a type': USBHIDKeyboard isn’t recognized, likely due to a missing or incorrect library.

  3. Protected init() and missing task(): The USBHost class has a protected init() method, and task() isn’t available.

Your intent was to use a USB keyboard without a "USB library" in the sense of avoiding external downloads, but since USBHostGiga.h (or alternatives like Arduino_USBHostMbed5) is part of the GIGA package, it’s likely acceptable. However, the current errors stem from an incorrect USB implementation. Let’s fix this by:

  • Using USBHostGiga.h (core GIGA library) correctly, as it’s designed for the GIGA R1 WiFi’s USB host functionality.

  • Keeping Adafruit_GFX.h and Adafruit_ST7735.h for the LCD (as in your original sketch).

Here’s the corrected sketch, reverting to the working USBHostGiga.h approach from your earlier code, avoiding the problematic USBHost and USBHIDKeyboard setup:


Corrected Code: USB Keyboard with USBHostGiga.h

cpp

WrapCopy

`#include <WiFi.h> // WiFi library for GIGA R1 (core)
#include <SPI.h> // SPI library (core)
#include <USBHostGiga.h> // USB host library for GIGA R1 (core)
#include <Adafruit_GFX.h> // Graphics library for LCD
#include <Adafruit_ST7735.h> // ST7735 library for LCD

// ST7735 pin definitions
#define TFT_CS 10 // PB10 - Chip Select
#define TFT_RST 9 // PB9 - Reset
#define TFT_DC 8 // PB8 - Data/Command
#define TFT_MOSI 15 // PB15 - SPI1 MOSI
#define TFT_SCLK 13 // PB13 - SPI1 SCK

// Initialize ST7735 LCD
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// USB keyboard setup
USBHostGiga usbHost;
KeyboardController keyboard(usbHost);

// Variables for WiFi setup
String inputString = "";
String ssid = "";
String password = "";
bool enteringSSID = true;
bool enteringPassword = false;
bool wifiConnected = false;

// Variables for URL input
String url = "";
bool enteringURL = false;
bool fetchRequested = false;

void setup() {
Serial.begin(115200); // Start Serial for debugging

// Initialize LCD
tft.initR(INITR_BLACKTAB); // Initialize ST7735
tft.setRotation(1); // Landscape mode
tft.fillScreen(ST7735_BLACK);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(0, 0);
tft.print("Enter SSID:");

// Start USB host
usbHost.begin();
}

void loop() {
usbHost.Task(); // Process USB events

if (!wifiConnected) {
handleWiFiSetup(); // Handle WiFi connection via keyboard
} else if (!enteringURL && !fetchRequested) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Enter URL:");
enteringURL = true;
} else if (fetchRequested) {
fetchWebContent();
}
}

// Keyboard callback
void keyPressed() {
char key = keyboard.getKey();
if (key >= 32 && key <= 126) { // Printable characters
inputString += key;
displayInput();
} else if (key == 13) { // Enter key
if (enteringSSID) {
ssid = inputString;
inputString = "";
enteringSSID = false;
enteringPassword = true;
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Enter Password:");
} else if (enteringPassword) {
password = inputString;
inputString = "";
enteringPassword = false;
connectToWiFi();
} else if (enteringURL) {
url = inputString;
inputString = "";
enteringURL = false;
fetchRequested = true;
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Fetching...");
}
}
}

void displayInput() {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
if (enteringSSID) {
tft.print("Enter SSID:");
} else if (enteringPassword) {
tft.print("Enter Password:");
} else if (enteringURL) {
tft.print("Enter URL:");
}
tft.setCursor(0, 20);
tft.print(inputString);
}

void connectToWiFi() {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Connecting to ");
tft.print(ssid);

WiFi.begin(ssid.c_str(), password.c_str());
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 20) {
delay(500);
Serial.print(".");
attempts++;
}

if (WiFi.status() == WL_CONNECTED) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("WiFi Connected");
wifiConnected = true;
delay(2000);
} else {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("WiFi Failed");
delay(2000);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Enter SSID:");
enteringSSID = true;
wifiConnected = false;
}
}

void fetchWebContent() {
WiFiClient client;
const int httpPort = 80;

// Parse URL into host and path
String urlStr = url;
int slashIndex = urlStr.indexOf('/');
String host = (slashIndex == -1) ? urlStr : urlStr.substring(0, slashIndex);
String path = (slashIndex == -1) ? "/" : urlStr.substring(slashIndex);

if (!client.connect(host.c_str(), httpPort)) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Connection failed");
delay(2000);
fetchRequested = false;
enteringURL = true;
return;
}

// Send HTTP GET request
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");

// Wait for response
while (client.connected() || client.available()) {
if (client.available()) {
String line = client.readStringUntil('\n');
if (line == "\r") { // Skip headers
break;
}
}
}

// Display body content
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print(url); // Show entered URL
int lineNum = 1;
while (client.available()) {
String line = client.readStringUntil('\n');
tft.setCursor(0, lineNum * 10); // 10px per line
if (lineNum < 16) { // Fit within 160px height
if (line.length() > 20) {
tft.print(line.substring(0, 20)); // Truncate to 20 chars
} else {
tft.print(line);
}
}
lineNum++;
}
client.stop();
fetchRequested = false;
enteringURL = true; // Return to URL input
}

void handleWiFiSetup() {
if (!enteringSSID && !enteringPassword && !wifiConnected) {
connectToWiFi();
}
}`


Fixing Your Errors

Your errors came from an attempt to use USBHost and USBHIDKeyboard (possibly from Arduino_USBHostMbed5), which isn’t the right approach for the GIGA R1 WiFi:

  • Original Errors:

    • 'getHost' not a member: USBHost doesn’t have this method; USBHostGiga uses a simpler instantiation.

    • 'USBHIDKeyboard' not a type: This requires a different library (Arduino_USBHostMbed5), not aligned with GIGA’s USBHostGiga.h.

    • Protected init() and missing task(): USBHost methods differ from USBHostGiga’s begin() and Task().

The corrected code reverts to USBHostGiga.h, which is the standard, core-supported way to handle USB on the GIGA R1 WiFi.


Setup Requirements

  • Board Package: "Arduino Mbed OS GIGA Boards" via Tools > Board > Boards Manager > Select "Arduino GIGA R1 WiFi".

  • Libraries:

    • WiFi.h, SPI.h, USBHostGiga.h: Core GIGA package.

    • Adafruit_GFX.h, Adafruit_ST7735.h: Install via Sketch > Include Library > Manage Libraries.

  • Hardware: ST7735 LCD and USB keyboard connected.


Testing

  1. Compile and upload the sketch.

  2. Type SSID → Enter, password → Enter, URL (e.g., "example.com/test.txt") → Enter.

  3. Check LCD for WiFi status and fetched content.

  4. Use an HTTP server for testing (e.g., python -m http.server 80 with test.txt).


Troubleshooting Your Original Errors

If you still see errors:

  • USBHostGiga Issues: Ensure the GIGA board package is installed correctly:

    • Reinstall via Boards Manager.

    • Check C:\Users\Nelson\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga<version>\libraries\USBHostGiga.

  • Library Conflicts: Remove Arduino_USBHostMbed5 from C:\Users\Nelson\Documents\Arduino\libraries\ if present, as it’s conflicting with USBHostGiga.h.


Alternative Without USB Library

If you strictly mean "no USB library at all" (even core ones), USB keyboard input isn’t possible without a custom driver. Here’s the hardcoded fallback:

cpp

WrapCopy

`#include <WiFi.h> // WiFi library for GIGA R1 (core)
#include <SPI.h> // SPI library (core)
#include <Adafruit_GFX.h> // Graphics library for LCD
#include <Adafruit_ST7735.h> // ST7735 library for LCD

// ST7735 pin definitions
#define TFT_CS 10 // PB10 - Chip Select
#define TFT_RST 9 // PB9 - Reset
#define TFT_DC 8 // PB8 - Data/Command
#define TFT_MOSI 15 // PB15 - SPI1 MOSI
#define TFT_SCLK 13 // PB13 - SPI1 SCK

// Initialize ST7735 LCD
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// Hardcoded WiFi credentials
const char* ssid = "YourWiFiSSID"; // Replace with your WiFi SSID
const char* password = "YourWiFiPassword"; // Replace with your WiFi password

// Hardcoded URL
const char* url = "example.com/test.txt"; // Replace with your HTTP URL
bool wifiConnected = false;
bool fetchRequested = true;

void setup() {
Serial.begin(115200); // Start Serial for debugging

// Initialize LCD
tft.initR(INITR_BLACKTAB); // Initialize ST7735
tft.setRotation(1); // Landscape mode
tft.fillScreen(ST7735_BLACK);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(0, 0);
tft.print("Connecting to WiFi...");

connectToWiFi();
}

void loop() {
if (wifiConnected && fetchRequested) {
fetchWebContent();
fetchRequested = false;
}
}

void connectToWiFi() {
WiFi.begin(ssid, password);
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 20) {
delay(500);
Serial.print(".");
attempts++;
}

if (WiFi.status() == WL_CONNECTED) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("WiFi Connected");
wifiConnected = true;
delay(2000);
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Fetching...");
} else {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("WiFi Failed");
while (true); // Halt if WiFi fails
}
}

void fetchWebContent() {
WiFiClient client;
const int httpPort = 80;

// Parse URL into host and path
String urlStr = String(url);
int slashIndex = urlStr.indexOf('/');
String host = (slashIndex == -1) ? urlStr : urlStr.substring(0, slashIndex);
String path = (slashIndex == -1) ? "/" : urlStr.substring(slashIndex);

if (!client.connect(host.c_str(), httpPort)) {
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print("Connection failed");
return;
}

// Send HTTP GET request
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");

// Wait for response
while (client.connected() || client.available()) {
if (client.available()) {
String line = client.readStringUntil('\n');
if (line == "\r") { // Skip headers
break;
}
}
}

// Display body content
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.print(url); // Show URL
int lineNum = 1;
while (client.available()) {
String line = client.readStringUntil('\n');
tft.setCursor(0, lineNum * 10); // 10px per line
if (lineNum < 16) { // Fit within 160px height
if (line.length() > 20) {
tft.print(line.substring(0, 20)); // Truncate to 20 chars
} else {
tft.print(line);
}
}
lineNum++;
}
client.stop();
}`


Recommendation

  • Version 1: Use this if USBHostGiga.h is acceptable (it’s core to GIGA, not an external download). It matches your original intent with USB input.

  • Version 2: Use this if you absolutely reject any USB library, but it eliminates USB functionality.

Please confirm:

  • Is USBHostGiga.h okay since it’s part of the GIGA package?

  • If not, are you okay with Version 2’s hardcoded approach?

but I try it again,it can't work too

Then ask you friend why

the screen's jump wire (png) I need