Skip to content

achildrenmile/morsefleet

Repository files navigation

MorseFleet

Featured on oeradio.at Live Demo License: MIT

🎙️ Part of the oeradio.at open source ham radio tool collection. Browse all tools → oeradio.at/werkzeuge

Morse Code Naval Battle Trainer - Learn Morse code while playing battleship against the computer!

MorseFleet License Languages

Overview

MorseFleet is an interactive web-based game that combines the classic battleship game with Morse code learning. Players input coordinates using a Morse key (or spacebar) and engage in turn-based naval combat against a computer opponent.

Live Demo: https://morsefleet.oeradio.at/

Features

Two-Way Gameplay

  • Ship Placement Phase: Place your 6 ships on a 7x7 grid
    • Click to place, press R to rotate
    • Random placement option available
  • Turn-Based Combat: You shoot, then the computer shoots back
  • Win/Lose Conditions: First to sink all enemy ships wins

Morse Code Input

  • Physical Morse key simulation (click or hold spacebar)
  • Short press = dot (.), Long press = dash (-)
  • Automatic character recognition after pause
  • Audio feedback with authentic Morse tones

Hardware Morse Key Support

  • USB HID (Keyboard Emulation) - Works in all browsers
    • Connect real CW paddles via USB HID adapters
    • Compatible with VBand, Pi Pico (pico_vband), and similar devices
    • Configurable key presets (VBand, morsecode.me, custom)
  • Web Serial API - Chrome/Edge only
    • Direct USB serial connection for Morserino-32 or DIY Arduino adapters
    • Multiple protocols: Simple Binary, ASCII, Morserino
    • Configurable baud rate (9600-115200)
  • Multiple keyer modes:
    • Straight Key: Manual timing of all elements
    • Bug (Semi-Auto): Automatic dits, manual dahs
    • Iambic A/B: Alternating dits and dahs with squeeze keying
    • Ultimatic: Last paddle pressed takes priority
  • Adjustable keyer speed (10-30 WPM)
  • Click ⚙️ in the status bar to configure

Smart Computer AI

  • Hunt-and-target algorithm
  • Checkerboard pattern for efficient hunting
  • Line tracking when multiple hits detected

Multi-Language Support

  • German (Deutsch)
  • English
  • Slovenian (Slovenščina)

Game Modes

  • Normal Mode: Uses letters A-G and numbers 1-7 (2 Morse characters per coordinate)
  • Advanced Mode: Uses letter pairs AB-MN and number pairs 01-13 (4 Morse characters per coordinate)
    • Learn the full alphabet A-N and all digits 0-9

Additional Features

  • Adjustable speed (10-25 WPM)
  • Interactive tutorial with live demo
  • Autoplay mode to watch the game play itself
  • Built-in Morse code reference (updates based on game mode)
  • Mobile-responsive design
  • No cookies, no tracking

How to Play

  1. Place Your Ships: Click on the left grid to place ships. Press R to rotate. Click "Confirm Fleet" when done.

  2. Enter Morse Code: Hold the Morse key (or spacebar):

    • Short press (<200ms) = dot
    • Long press (>200ms) = dash
    • Pause to finalize character
  3. Send Coordinates: Enter a letter (A-G) + number (1-7), e.g., "B3", then click "Send"

  4. Interpret Response:

    • W (.--) = Water (miss)
    • S (...) = Hit
    • K (-.-) = Sunk
  5. Survive: Watch for incoming enemy fire on your fleet grid!

Morse Reference

Normal Mode (A-G, 1-7)

Letters:        Numbers:
A = .-          1 = .----
B = -...        2 = ..---
C = -.-.        3 = ...--
D = -..         4 = ....-
E = .           5 = .....
F = ..-.        6 = -....
G = --.         7 = --...

Advanced Mode (A-N, 0-9)

Letters:                    Numbers:
A = .-      H = ....       0 = -----
B = -...    I = ..         1 = .----
C = -.-.    J = .---       2 = ..---
D = -..     K = -.-        3 = ...--
E = .       L = .-..       4 = ....-
F = ..-.    M = --         5 = .....
G = --.     N = -.         6 = -....
                           7 = --...
                           8 = ---..
                           9 = ----.

Connecting a Hardware Morse Key

MorseFleet supports real CW paddles and keys. See HARDWARE_KEY_SUPPORT.md for detailed build guides.

Quick Start Options

Method Browser Support DIY Cost Difficulty
USB HID (Pi Pico) All browsers ~$5 Easy
USB HID (VBand) All browsers ~$25 Plug & Play
USB Serial (Arduino) Chrome/Edge only ~$5 Easy
Morserino-32 Chrome/Edge only ~$120 Plug & Play

DIY Serial Adapter (5 minutes)

For Chrome/Edge users, build a simple serial adapter:

Hardware:

  • Arduino Nano (~$5) or any Arduino with USB
  • 3.5mm stereo jack (~$0.50)

Wiring:

Arduino Nano          3.5mm TRS Jack
    D2  ─────────────── Tip (Dit)
    D3  ─────────────── Ring (Dah)
   GND  ─────────────── Sleeve (Ground)

Firmware (upload via Arduino IDE):

const int DIT_PIN = 2, DAH_PIN = 3;
byte lastState = 0;

void setup() {
    pinMode(DIT_PIN, INPUT_PULLUP);
    pinMode(DAH_PIN, INPUT_PULLUP);
    Serial.begin(115200);
}

void loop() {
    byte state = (!digitalRead(DIT_PIN) << 1) | !digitalRead(DAH_PIN);
    if (state != lastState) {
        Serial.write(state);
        lastState = state;
    }
    delay(5);
}

In MorseFleet: Settings ⚙️ → Serial (USB) → Baud: 115200 → Protocol: Simple Binary → Connect

Technical Details

  • Single-file SPA: Everything in one HTML file (~7000 lines)
  • No dependencies: Pure HTML, CSS, JavaScript
  • Web Audio API: For Morse tone generation
  • Web Serial API: Direct serial port access (Chrome/Edge)
  • LocalStorage: For language preference and key settings
  • Docker-ready: Includes Dockerfile and nginx config

Project Structure

morsefleet/
├── morsefleet.html           # Main application (single-file SPA)
├── config.json               # Optional parent site branding
├── nginx.conf                # Nginx configuration
├── Dockerfile                # Docker build configuration
├── docker-entrypoint.sh      # Container startup script
├── deploy-production.sh      # Deployment script
├── HARDWARE_KEY_SUPPORT.md   # Hardware Morse key implementation docs
└── README.md                 # This file

Deployment

Local Development

Simply open morsefleet.html in a browser - no server required.

Docker Deployment

docker build -t morsefleet .
docker run -d -p 80:80 morsefleet

Production Deployment

./deploy-production.sh

Configuration

Optional config.json for parent site branding:

{
  "parentSiteUrl": "https://example.com",
  "parentSiteLogo": "logo.png",
  "parentSiteName": "Example Site"
}

Credits

License

MIT License - See source code for details.


73 de OE8YML - Good luck and have fun learning Morse code!

About

Learn Morse code by navigating a fleet — a CW training game for amateur radio

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors