Skip to content

Vishnu-3727/Console

Repository files navigation

🎮 Dual-Track Controller

Competition-ready web controller for dual-track vehicles with 6 fixed throttle levels and Bluetooth Arduino control.

🌐 LIVE WEB APP

Test URL: http://192.168.137.129:8001

Desktop: Open in browser → Use W/A/S/D + 1-6 keys Mobile: Open on phone (same WiFi) → Touch controls

⚡ Features

  • 6 Fixed Throttle Levels: 40, 80, 120, 160, 200, 250 RPM
  • Strict Motor Control Rules: Independent LEFT/RIGHT motor control
  • Real-time Bluetooth: 20 Hz update rate
  • Industrial UI: Tech-themed design with grid layout
  • Emergency Stop: Immediate cutoff with priority
  • PWA Support: Installable as native app

🎯 Motor Control Rules

FORWARD:  LEFT=FWD  + RIGHT=FWD
BACKWARD: LEFT=BWD  + RIGHT=BWD
LEFT:     LEFT=OFF  + RIGHT=FWD  (right motor only)
RIGHT:    LEFT=FWD  + RIGHT=OFF  (left motor only)
STOP:     LEFT=OFF  + RIGHT=OFF

🎮 Controls

Touch/Click

  • Throttle Buttons: Tap 1-6 to select speed level
  • Direction Buttons: W/A/S/D layout
  • Emergency Stop: Large red button

Keyboard

  • W - Forward
  • S - Backward
  • A - Left turn
  • D - Right turn
  • 1-6 - Select throttle level
  • SPACE - Emergency stop
  • Q - Quit (stop motors)

📊 Throttle Levels

Level RPM PWM Use Case
1 40 41 Precision control
2 80 82 Slow movement
3 120 122 Default
4 160 163 Medium speed
5 200 204 Fast movement
6 250 255 Maximum speed

🔌 Hardware Setup

Required Components

  • Arduino Uno/Nano/Mega
  • HC-05 Bluetooth Module
  • L298N Motor Driver
  • 2 DC Motors (max 250 RPM)
  • Power supply (7-12V)

Wiring

HC-05 to Arduino:

HC-05 VCC → 5V
HC-05 GND → GND
HC-05 TX  → Pin 10
HC-05 RX  → Pin 11 (via voltage divider!)

L298N Motor 1 (LEFT):

IN1 → Pin 5
IN2 → Pin 6
ENA → Pin 3 (PWM)

L298N Motor 2 (RIGHT):

IN3 → Pin 9
IN4 → Pin 10
ENB → Pin 11 (PWM)

🚀 Quick Start

  1. Upload Arduino Sketch

    • Open arduino/track_controller.ino
    • Set SIMULATION_MODE = true for LED testing
    • Upload to Arduino
  2. Configure HC-05

    AT+NAME=TrackController
    AT+PSWD=1234
    AT+UART=38400,0,0
    
  3. Pair Bluetooth

    • Phone Settings → Bluetooth
    • Connect to "TrackController" (PIN: 1234)
  4. Open Web App

    • Navigate to: http://192.168.137.129:8001
    • Click "CONNECT BLUETOOTH"
    • Select device from list
  5. Test Controls

    • Select throttle level (default: 3)
    • Press direction buttons
    • Watch motor status update

📱 Convert to APK

Method 1: PWA Builder

  1. Deploy to GitHub Pages/Netlify
  2. Visit pwabuilder.com
  3. Enter your URL
  4. Download Android APK

Method 2: Capacitor

npm install @capacitor/core @capacitor/cli @capacitor/android
npx cap init
npx cap add android
npx cap open android
# Build APK in Android Studio

🔬 Serial Protocol

Packet Format: <M1_DIR,M1_PWM,M2_DIR,M2_PWM,SAFE>\n

Direction Codes:

  • 0 = STOP
  • 1 = FORWARD
  • 2 = BACKWARD

Examples:

<1,122,1,122,0>  → Both forward at level 3 (120 RPM)
<0,0,1,163,0>    → Left turn at level 4 (160 RPM)
<1,204,0,0,0>    → Right turn at level 5 (200 RPM)
<0,0,0,0,1>      → Emergency stop

🛡️ Safety Features

Emergency Stop: Overrides all commands ✅ Watchdog Timer: Arduino auto-stops after 500ms no packet ✅ Disconnect Handling: Auto-stop on Bluetooth disconnect ✅ PWM Clamping: Enforced 0-255 range ✅ Motor Rule Validation: Strict turn logic enforced

🧪 Testing

LED Simulation Mode

Set SIMULATION_MODE = true in Arduino sketch:

  • Pin 2: Motor 1 Forward LED
  • Pin 4: Motor 1 Backward LED
  • Pin 7: Motor 2 Forward LED
  • Pin 8: Motor 2 Backward LED
  • Pin 13: Emergency LED

Web App Testing

  1. Open browser console (F12)
  2. Watch packet logs
  3. Test each throttle level
  4. Verify motor states update correctly

📂 Project Structure

track-controller/
├── index.html           # Main interface
├── styles.css           # Industrial theme
├── app.js               # Controller logic
├── manifest.json        # PWA config
├── service-worker.js    # Offline support
└── arduino/
    └── track_controller.ino  # Arduino sketch

🐛 Troubleshooting

Bluetooth won't connect

  • Pair HC-05 in phone Settings first
  • Use Chrome browser (best Web Bluetooth support)
  • Check HC-05 is powered and blinking

Motors don't respond

  • Check L298N power supply (7-12V)
  • Verify wiring (TX/RX not swapped)
  • Test with LED simulation mode first
  • Check Serial Monitor for packets

Wrong motor direction

  • Swap motor wires on L298N output
  • Or modify Arduino pin assignments

📊 Performance

  • Update Rate: 20 Hz (50ms interval)
  • Latency: <50ms touch to motor
  • Packet Size: ~20 bytes
  • Bluetooth Range: ~10 meters

🏁 Competition Ready

This system is designed for robotics competitions:

  • Deterministic throttle levels
  • Instant stop behavior
  • Fail-safe mechanisms
  • Clean motor control rules
  • Professional UI

Project: Dual-Track Controller v1.0 License: MIT Built for: Competition Robotics

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors