Skip to content

Visuals.md

Trent M. Wyatt edited this page Apr 21, 2025 · 1 revision

Visuals

This page describes the visual outputs of MicroChess, which displays the chess board and game state in two ways: an 8x8 LED strip (using the FastLED library) and the Arduino Serial Monitor. These visualizations, implemented in led_strip.cpp and MicroChess.ino, enhance user interaction and make the game accessible on resource-constrained Arduino boards (less than 2K RAM).

Overview

MicroChess provides two primary methods to visualize the game:

  • LED Strip: An 8x8 grid of LEDs displays the chess board, with pieces represented by colors.
  • Serial Console: The Arduino Serial Monitor prints the board as text, along with move history and prompts for user input. These outputs reflect the current board state and update in real-time as moves are made, either by the engine or the user.

LED Strip Display

The LED strip display is managed by led_strip.cpp, using the FastLED library to control an 8x8 matrix of LEDs (e.g., WS2812B LEDs).

Features

  • Board Representation:
    • The 8x8 grid corresponds to the chess board (a1 to h8).
    • Each square’s LED shows a piece’s presence, type, and color using distinct colors.
  • Color Mapping:
    • White pieces: Light colors (e.g., white for king, light blue for pawns).
    • Black pieces: Darker colors (e.g., red for king, dark green for pawns).
    • Empty squares: Off or a neutral color (e.g., dim gray).
    • Exact colors are defined in led_strip.cpp and depend on the LED hardware.
  • Real-Time Updates:
    • The display refreshes after each move, reflecting the updated board_t state.
    • Smooth transitions ensure a visually appealing experience.

Setup

  • Requires an 8x8 LED matrix or strip connected to the Arduino (e.g., data pin 6).
  • The FastLED library must be installed (see Installation).
  • Configuration details (e.g., pin number, LED type) are in led_strip.cpp.

Visual Demo

  • See MicroChessSmall.gif for a demonstration of the LED strip displaying the board during a game.

Serial Console Output

The Serial Monitor output is handled by MicroChess.ino, printing the board and game information as text.

Features

  • Board Display:
    • Prints an 8x8 grid representing the board, with ranks (1-8) and files (a-h).
    • Pieces are shown as letters:
      • White: Uppercase (e.g., P=pawn, N=knight, B=bishop, R=rook, Q=queen, K=king).
      • Black: Lowercase (e.g., p=pawn, n=knight).
      • Empty squares: Dots (.).
    • Example:
      r n b q k b n r
      p p p p p p p p
      . . . . . . . .
      . . . . . . . .
      . . . . . . . .
      . . . . . . . .
      P P P P P P P P
      R N B Q K B N R
      
  • Move History:
    • Displays each move in algebraic notation (e.g., "e2e4", "g8f6").
    • Shows whose turn it is (e.g., "Enter move for White:").
  • Prompts and Feedback:
    • Prompts for user input in interactive mode.
    • Reports errors (e.g., "Illegal move") for invalid inputs.
  • Game State:
    • Indicates check, checkmate, stalemate, or draw when applicable.

Setup

  • Open the Serial Monitor in the Arduino IDE (Tools > Serial Monitor, baud rate: 9600).
  • No additional hardware is required beyond the Arduino and USB connection.

Visual Demo

  • See MicroChessConsole2.gif for a demonstration of the Serial Monitor output, showing the board and move interactions.

Integration with Other Components

The visual outputs rely on:

  • Board Representation (board.h/cpp): Provides the board_t state to map pieces to LEDs or text.
  • Game Logic (game.h/cpp): Triggers updates after each move or game state change.
  • Move Generation (move.h/cpp): Supplies move data for display in the Serial Monitor.
  • Search Algorithm (MicroChess.ino): Determines moves that are visualized.

Usage

  • LED Strip: Automatically displays the board when the Arduino is powered on, if connected. No user action is needed unless customizing colors in led_strip.cpp.
  • Serial Monitor: Open the Serial Monitor to view the board and interact with the game (see Usage for details on entering moves).

Troubleshooting

  • LED Strip Not Displaying:
    • Verify the FastLED library is installed and the LED matrix is connected correctly.
    • Check led_strip.cpp for correct pin and LED type settings.
  • Serial Monitor Blank:
    • Ensure the baud rate is 9600 and the correct port is selected.
    • Confirm the Arduino is powered and the sketch is uploaded.

Next Steps

  • Explore Options to customize display settings (e.g., verbosity).
  • See Usage for interacting with the visual outputs.
  • Check Code Structure for an overview of all files.

Back to Home | Next: Options

Clone this wiki locally