A smart soccer table (foosball) controller built with ESP32 that features automatic goal detection using IR sensors and LED strip celebrations with team-specific colors.
- Automatic Goal Detection: IR sensors in each goal detect when a ball passes through
- 10-Point Game System: Complete games with automatic win detection at 10 points
- LED Strip Celebrations: 5-meter WS2812B LED strip displays team-specific color waves when goals are scored
- Game Win Celebrations: Extended 10-second celebrations when a team wins the game
- Score Tracking: Automatic score counting for both teams with game status
- Non-blocking Architecture: All systems run simultaneously without delays
- Team Colors: Team A (Yellow) vs Team B (Orange) celebrations
- Game Start: System initializes a new 10-point game automatically
- Normal Mode: LED strip cycles through beautiful demo effects (white, color waves, rainbow, breathing) during active gameplay
- Goal Detection: IR sensors detect when the ball blocks the beam in either goal
- Goal Celebration: Immediate 3-second team-colored LED celebration wave
- Score Tracking: Score increments automatically, displayed in Serial Monitor
- Game End: When a team reaches 10 points, a 10-second game win celebration triggers
- Auto Restart: After game win celebration, a new 10-point game starts automatically
- ESP32 Development Board (ESP32-DevKit or similar)
- WS2812B LED Strip - 5 meters, 60 LEDs/meter (300 total LEDs)
- 2x IR Reflective Sensors - For goal detection (e.g., TCRT5000)
- 5V Power Supply - For LED strip (calculate based on LED count)
- Jumper Wires and Breadboard
The 5-meter strip is divided into 4 sections around the table perimeter:
- Section 1: 120cm (72 LEDs) - LEDs 0-71
- Section 2: 70cm (42 LEDs) - LEDs 72-113
- Section 3: 120cm (72 LEDs) - LEDs 114-185
- Section 4: 70cm (42 LEDs) - LEDs 186-227
- Unused: 72 LEDs (228-299)
ESP32 Pin 2 โ LED Strip Data In
ESP32 Pin 18 โ IR Sensor Goal 1 (Team A - Red)
ESP32 Pin 19 โ IR Sensor Goal 2 (Team B - Blue)
5V Supply โ LED Strip VCC
GND โ LED Strip GND + IR Sensors GND + ESP32 GND
3.3V โ IR Sensors VCC
esp32-soccer-table/
โโโ platformio.ini # PlatformIO configuration
โโโ include/
โ โโโ led-controller.h # LED strip control declarations
โ โโโ ir-controller.h # IR sensor declarations
โโโ src/
โ โโโ main.cpp # Main application code
โ โโโ led-controller.cpp # LED strip implementation
โ โโโ ir-controller.cpp # IR sensor implementation
โโโ README.md # This file
- Install PlatformIO IDE or use PlatformIO extension in VS Code
- Clone or download this repository
If using different pins, update the pin definitions in the header files:
// In include/led-controller.h
#define LED_PIN 2
// In include/ir-controller.h
#define IR_SENSOR_GOAL_1_PIN 18
#define IR_SENSOR_GOAL_2_PIN 19- Connect your ESP32 to your computer
- Open the project in PlatformIO
- Build and upload:
pio run --target upload - Open Serial Monitor:
pio device monitor(baud rate: 9600)
- Power on the system
- LED strip will show white light initially
- Demo effects cycle every 10 seconds when not playing
- Start playing - the system is always ready for a 10-point game
- When a goal is scored, the IR sensor detects it immediately
- LED strip shows a 3-second celebration in team colors:
- Team A Goal: Yellow wave celebration
- Team B Goal: Orange wave celebration
- Score is automatically tracked and displayed in Serial Monitor
- Game Win: When a team reaches 10 points:
- 10-second extended game win celebration in team colors
- Game automatically restarts after celebration
- After goal celebrations, demo effects resume (only during active games)
ESP32 Soccer Table - WiFi Setup
================================
LED strip initialized with 300 LEDs
IR sensors initialized:
- Goal 1 (Team A) sensor on pin 18
- Goal 2 (Team B) sensor on pin 19
โฝ Soccer table ready for 10-point games! โฝ
๐ Starting new game! First to 10 points wins! ๐
๐ Game Status:
๐ฏ Target: 10 points to win
Current Score - Team A: 0 | Team B: 0
โฝ Game is ACTIVE - Play on!
๐ฅ
GOAL SCORED! ๐ฅ
Team A (YELLOW) scored!
Current Score - Team A: 1 | Team B: 0
๐ Starting goal celebration for Team A (YELLOW)
๐๐๐ GAME WON! ๐๐๐
Team A (YELLOW) wins the game!
Current Score - Team A: 10 | Team B: 7
๐ Celebrating GAME WIN for Team A
New game will start automatically after celebration!
๐ Celebration ended
๐ Game win celebration ended - Starting new game!
๐ Starting new game! First to 10 points wins! ๐
๐ Game Status:
๐ฏ Target: 10 points to win
Current Score - Team A: 0 | Team B: 0
โฝ Game is ACTIVE - Play on!
You can modify the available effects in led-controller.h:
LED_FULL_WHITE- All sections whiteLED_COLOR_WAVE- Colored wave animationLED_RAINBOW_WAVE- Rainbow wave effectLED_BREATHING- Breathing/fade effect
Adjust timing in the header files:
#define POINTS_TO_WIN 10 // Points needed to win (easily configurable)
#define GOAL_CELEBRATION_DURATION 3000 // Goal celebration length (ms)
#define GAME_WIN_CELEBRATION_DURATION 10000 // Game win celebration length (ms)
#define IR_DEBOUNCE_TIME 500 // Goal detection debounce (ms)
#define WAVE_SPEED 50 // Wave animation speedChange team colors in led-controller.h:
#define TEAM_A_COLOR CRGB::Yellow // Team A color
#define TEAM_B_COLOR CRGB::Orange // Team B color- No LEDs lighting: Check 5V power supply and data pin connection
- Wrong colors: Verify
COLOR_ORDERin led-controller.h (try RGB vs GRB) - Flickering: Ensure stable 5V power supply with sufficient amperage
- No goal detection: Check sensor wiring and position
- False triggers: Increase
IR_DEBOUNCE_TIMEor adjust sensor sensitivity - Sensors always triggered: Check pull-up resistors and sensor polarity
- Use 9600 baud rate
- Check USB cable and driver installation
- Verify correct COM port selection
Create custom LED effects by adding new cases to the updateLEDs() function in led-controller.cpp.
- LED Strip: Up to 8 at full white (300 LEDs)
- IR Sensors: ~20mA each
Recommended: 5V 10A power supply for full brightness operation.
Feel free to contribute improvements:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is open source. Feel free to use, modify, and distribute.