This shows you the differences between two versions of the page.
|
pm:prj2026:jan.vaduva:139350 [2026/05/09 22:41] alexandru.strugariu |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Interactive Electronic Chessboard with RGB LEDs ====== | ||
| - | ===== Introduction ===== | ||
| - | |||
| - | The Interactive Electronic Chessboard is a project that aims to enhance the chess-playing experience by providing real-time visual feedback through individually addressable RGB LEDs placed under each of the 64 squares. Pieces are detected using a matrix of reed switches and neodymium magnets embedded in the base of each piece. | ||
| - | |||
| - | When a player picks up a piece, the board highlights all legal moves in **green**, the selected square in **yellow**, and any check situation in **red**. Invalid moves trigger a short **red flash**. The board state is transmitted in real time to a laptop via UART, where a Python script displays the game. | ||
| - | |||
| - | **Purpose:** To create an interactive and educational chess experience that helps players — especially beginners — understand legal moves intuitively through direct visual feedback on the board. | ||
| - | |||
| - | **GitHub Repository:** To be announced | ||
| - | |||
| - | ===== General Description ===== | ||
| - | |||
| - | The system is split into two main subsystems: | ||
| - | |||
| - | * **Detection subsystem:** An 8×8 matrix of 64 reed switches, one per square. The ESP32 scans the matrix by driving each of the 8 row pins LOW one at a time and reading the 8 column pins. When a piece (with a N52 neodymium magnet in its base) is placed on a square, the corresponding reed switch closes and the column reads LOW — piece detected. | ||
| - | |||
| - | * **Lighting subsystem:** A WS2812B 60LED/m strip cut into 8 segments of 8 LEDs each, wired in a snake pattern (even rows left→right, odd rows right→left). All 64 LEDs are driven from a single GPIO4 pin using the WS2812B one-wire protocol, implemented via the ESP32's hardware RMT peripheral. | ||
| - | |||
| - | * **UART communication:** On every board state change, the ESP32 sends the updated board state to the laptop at 115200 baud via USB-Serial. A Python script reads the data and displays the game graphically. | ||
| - | |||
| - | === Block Diagram === | ||
| - | |||
| - | {{:pm:prj2026:jan.vaduva:schema_bloc_strugariu_alexandru.png?600|}} | ||
| - | |||
| - | ===== Hardware Design ===== | ||
| - | |||
| - | === Bill of Materials === | ||
| - | |||
| - | ^ No ^ Component ^ Role ^ | ||
| - | | 1 | ESP32-WROOM-32D DevKit 38P | Main microcontroller, 240MHz dual-core | | ||
| - | | 2 | WS2812B LED strip 60LED/m IP30, 2×1m | 64 individually addressable RGB LEDs | | ||
| - | | 3 | Reed switch N/O 2×14mm, 100 pcs | Piece presence detection on each square | | ||
| - | | 4 | Neodymium magnet N52 disc 5×2mm, 50 pcs | Embedded in piece bases | | ||
| - | | 5 | 5V 3A DC power supply | Powers the LED strip | | ||
| - | | 6 | 330Ω resistor 1/4W | DATA line protection for WS2812B | | ||
| - | | 7 | 10kΩ resistors 1/4W, 8 pcs | Pull-up on column lines (GPIO34/35 mandatory external) | | ||
| - | | 8 | Electrolytic capacitor 1000µF 6.3V | Inrush current protection for LED strip | | ||
| - | | 9 | Ceramic capacitors 100nF, 3 pcs | Decoupling on ESP32 power supply | | ||
| - | | 10 | Dupont wires 30cm (M-M, M-F, F-F) | Component interconnections | | ||
| - | | 11 | Chess set with pieces | Game pieces (magnets embedded in bases) | | ||
| - | |||
| - | |||
| - | === Pin Mapping === | ||
| - | |||
| - | ^ GPIO ^ Function ^ Direction ^ | ||
| - | | GPIO4 | WS2812B DATA (through 330Ω) | OUTPUT | | ||
| - | | GPIO2 | Row R1 | OUTPUT | | ||
| - | | GPIO0 | Row R2 | OUTPUT | | ||
| - | | GPIO18 | Row R3 | OUTPUT | | ||
| - | | GPIO19 | Row R4 | OUTPUT | | ||
| - | | GPIO27 | Row R5 | OUTPUT | | ||
| - | | GPIO14 | Row R6 | OUTPUT | | ||
| - | | GPIO12 | Row R7 | OUTPUT | | ||
| - | | GPIO13 | Row R8 | OUTPUT | | ||
| - | | GPIO32 | Column A | INPUT + internal pull-up | | ||
| - | | GPIO33 | Column B | INPUT + internal pull-up | | ||
| - | | GPIO34 | Column C | INPUT + **external** 10kΩ pull-up (input-only pin) | | ||
| - | | GPIO35 | Column D | INPUT + **external** 10kΩ pull-up (input-only pin) | | ||
| - | | GPIO15 | Column E | INPUT + internal pull-up | | ||
| - | | GPIO16 | Column F | INPUT + internal pull-up | | ||
| - | | GPIO17 | Column G | INPUT + internal pull-up | | ||
| - | | GPIO5 | Column H | INPUT + internal pull-up | | ||
| - | |||
| - | === Electrical Schematic === | ||
| - | |||
| - | //Schematic to be added// | ||
| - | |||
| - | ===== Software Design ===== | ||
| - | |||
| - | === Development Environment === | ||
| - | |||
| - | * **Arduino IDE 2.x** with esp32 by Espressif Systems v3.3.8 | ||
| - | * **Python 3.x** on laptop for board visualization | ||
| - | |||
| - | === Libraries Used === | ||
| - | |||
| - | * **FastLED** — WS2812B strip control, individual RGB LED addressing | ||
| - | * **Arduino Serial** (built-in) — UART communication with laptop at 115200 baud | ||
| - | |||
| - | === Firmware Description === | ||
| - | |||
| - | **Matrix scanning:** The ESP32 drives each of the 8 row pins LOW sequentially (~100Hz scan rate) and reads the 8 column pins. The result is a 64-bit board occupancy map stored as ''uint8_t board_state[8]''. | ||
| - | |||
| - | **Board state representation:** ''uint8_t board[64]'' — lower 3 bits = piece type (0=empty, 1=pawn, 2=rook, 3=knight, 4=bishop, 5=queen, 6=king), bit 3 = color (0=white, 1=black). | ||
| - | |||
| - | **Chess logic:** Legal move generation for all piece types. On piece lift, computes all valid destination squares. Detects check and checkmate conditions. | ||
| - | |||
| - | **LED control:** On every state change, computes the color map for all 64 LEDs and pushes it via FastLED. Colors: green = valid move, yellow = selected piece, red = check/invalid move, off = empty square. | ||
| - | |||
| - | **UART output:** On every confirmed move, sends board state in simplified FEN notation at 115200 baud. | ||
| - | |||
| - | === Main Algorithm === | ||
| - | |||
| - | <code cpp> | ||
| - | void loop() { | ||
| - | scan_matrix(board_state); // read all 64 reed switches | ||
| - | |||
| - | if (board_state != prev_state) { | ||
| - | compute_delta(prev_state, board_state); | ||
| - | |||
| - | if (piece_lifted) { | ||
| - | legal_moves = get_legal_moves(from_square); | ||
| - | set_leds_green(legal_moves); | ||
| - | set_led_yellow(from_square); | ||
| - | } | ||
| - | |||
| - | if (piece_placed) { | ||
| - | if (is_valid_move(from_square, to_square)) { | ||
| - | update_board(from_square, to_square); | ||
| - | switch_turn(); | ||
| - | send_uart_fen(); | ||
| - | if (king_in_check()) set_led_red(king_square); | ||
| - | } else { | ||
| - | flash_red(to_square); // invalid move feedback | ||
| - | } | ||
| - | } | ||
| - | |||
| - | FastLED.show(); | ||
| - | prev_state = board_state; | ||
| - | } | ||
| - | } | ||
| - | </code> | ||
| - | |||
| - | ===== Results ===== | ||
| - | |||
| - | * Correct detection of all 64 squares via reed switch matrix | ||
| - | * Visual response time under 50ms from piece lift/place | ||
| - | * Stable UART communication at 115200 baud with Python script | ||
| - | * Total power consumption under 2A at 50% LED brightness | ||
| - | |||
| - | ===== Conclusions ===== | ||
| - | |||
| - | The project successfully demonstrates the integration of multiple ESP32 peripherals — GPIO matrix scanning, RMT hardware for WS2812B, and UART — into a functional hardware product. The RGB LED visual feedback proved intuitive for indicating legal moves, and the reed switch matrix provided reliable piece detection without complex analog circuitry. | ||
| - | |||
| - | ===== Download ===== | ||
| - | |||
| - | To be posted. | ||
| - | |||
| - | ---- | ||
| - | **Author:** Alexandru-Constantin Strugariu \\ | ||
| - | **Group:** 333CD \\ | ||
| - | **Lab Assistant:** Jan Alexandru Văduva \\ | ||