# JackBot Board Firmware `BoardCode/` contains the firmware sketches for running JackBot on microcontroller boards. The Python simulator, manual-control application, and host-side communication configuration are documented in the [main README](../README.md). ## Sketches | Sketch | Purpose | | --- | --- | | [`JackBotEsp32/JackBotEsp32.ino`](JackBotEsp32/JackBotEsp32.ino) | ESP32 firmware using the shared JackBot library and UDP networking. | | [`JackBotEsp32C3/JackBotEsp32C3.ino`](JackBotEsp32C3/JackBotEsp32C3.ino) | ESP32-C3 variant of the networked firmware. It initializes I2C on GPIO 6 and 7. | | [`JackBotArd/JackBotArd.ino`](JackBotArd/JackBotArd.ino) | Separate Arduino sketch using Bluetooth serial and PCA9685 servo boards. | The ESP32 sketches use [`libaries/JackBot/`](libaries/JackBot/) (the directory name is spelled `libaries` in this repository). That library contains: * `BotNetwork` for Wi-Fi/UDP packet handling; * `MotionController` for PCA9685 servo output and motion interpolation; * `DisplayManager` for the ST7789 display; and * `Protocol.h` for packet type and header definitions. The `JackBotArd` sketch is a separate, older implementation; it does not use this shared ESP32 library. ## Build and upload 1. Install the Arduino IDE or Arduino CLI and the Espressif ESP32 board support package. 2. Install the libraries required by the selected sketch. The ESP32 sketches use Adafruit PWM Servo Driver, Adafruit GFX, and Adafruit ST7735 and ST7789. The classic `JackBotArd` sketch uses Adafruit PWM Servo Driver and additionally includes `JackBotEmotes.h`; that dependency is not present in the shared `libaries/JackBot` library. 3. Add `libaries/JackBot` as a local Arduino library (or copy it into your Arduino libraries directory) before building either ESP32 sketch. 4. Open the desired `.ino` file, select the matching ESP32 board and serial port, then build and upload it. Check the pin assignments in the selected sketch and the board's wiring before powering servos or displays. The ESP32-C3 sketch explicitly sets I2C to GPIO 6/7; the classic ESP32 sketch uses the board's default `Wire` pins. Display pins are specified when `DisplayManager` is constructed in each sketch. ## Network connection The ESP32 sketches listen for UDP packets on port `3323` through `BotNetwork`. The network library is configured in the sketch constructor with Wi-Fi and fallback access-point settings. Set these to the values for your installation before upload; do not commit real network passwords to source control. For host-side use, set `cfg.backend` to `BackendType.ESP32` and configure the ESP32 address and port in the root project's `config.py`. The host communication layer and heartbeat behavior are described in the [main README](../README.md). ## Protocol and runtime notes `Protocol.h` defines versioned packet types for motion commands, configuration, display messages, and ping/pong packets. `BotNetwork` parses received packets and passes motion/configuration/display updates to the sketch. The ESP32 sketches use FreeRTOS tasks and queues so servo updates and display updates run separately from packet reception. The classic Arduino sketch instead reads framed Bluetooth serial input and drives two PCA9685 boards. It has a different transport and firmware path from the ESP32 UDP implementation.