Mithun Das
Published © GPL3+

Rechargeable Digital Foosball Scoreboard Using ESP8266

Imagine a digital scoreboard which is updated automatically when the ball enters the goal and play a beep sound!

IntermediateFull instructions provided16 hours954
Rechargeable Digital Foosball Scoreboard Using ESP8266

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1
IR Break Beam Sensor
×1
SparkFun 7-Segment Serial Display - Red
SparkFun 7-Segment Serial Display - Red
×1
Buzzer
Buzzer
×1
TP4056
Charging module
×1
Battery Holder, 18650 x 1
Battery Holder, 18650 x 1
×1
18650 Battery
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Multitool, Screwdriver
Multitool, Screwdriver
Soldering iron (generic)
Soldering iron (generic)
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron

Story

Read more

Custom parts and enclosures

foosball_scoreboard_main_(2)_nylYDBKijG.stl

foosball_scoreboard_lid_2_WuvP9liW2f.stl

Schematics

Circuit Diagram

Code

FoosballScorecard.ino

Arduino
#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK D6
#define DIO D5

#define REDSENSORPIN D3
#define BLUESENSORPIN D7

#define PUSHBUTTON 15 //D8  GPIO 15
#define BUZZPIN D2

// variables will change:
int redSensorState = 0, redLastState=0, blueSensorState = 0, blueLastState=0;         // variable for reading the pushbutton status
int redScore=0, blueScore=0;
int resetButttonPressed = 0;

String scoreCard="0000";



TM1637Display display(CLK, DIO);
uint8_t data[] =  { 0x0f, 0x0f, 0x0f, 0x0f };


void setup() {
  // initialize RED IR BEAM
  pinMode(REDSENSORPIN, INPUT_PULLUP);     
  digitalWrite(REDSENSORPIN, HIGH); // turn on the pullup

  // initialize BLUE IR BEAM
  pinMode(BLUESENSORPIN, INPUT_PULLUP);     
  digitalWrite(BLUESENSORPIN, HIGH); // turn on the pullup

  display.setBrightness(0x0f);
  //display.showNumberDecEx(105, 0b01000000, true, 4, 0);
  updateScore();
  
  
  pinMode(PUSHBUTTON,INPUT);
  pinMode(BUZZPIN,OUTPUT);
  
  Serial.begin(9600);
  Serial.println("Initialized....");
  
  
}



void loop(){
  // check status of RED IR BEAM
  redSensorState = digitalRead(REDSENSORPIN);

  //Serial.println(sensorState);
  
  if (redSensorState && !redLastState) {
    Serial.println("RED Unbroken");
    
  } 
  if (!redSensorState && redLastState) {
    Serial.println("RED Broken");
    redScore = redScore+1;
    updateScore();
    
  }
  
  redLastState = redSensorState;

  //check status of BLUE IR BEAM
  blueSensorState = digitalRead(BLUESENSORPIN);

  //Serial.println(sensorState);
  
  if (blueSensorState && !blueLastState) {
    Serial.println("BLUE Unbroken");
    
  } 
  if (!blueSensorState && blueLastState) {
    Serial.println("BLUE Broken");
    blueScore = blueScore+1;
    updateScore();
    
  }
  
  blueLastState = blueSensorState;

  //check for reset button pressed
  resetButttonPressed = digitalRead(PUSHBUTTON);
  //Serial.println(resetButttonPressed);
  
  if(resetButttonPressed == HIGH){
    //reset button is pressed
    resetScore();
  }
  
}

void resetScore(){
  Serial.println("Reset button pressed...");
  redScore=0; 
  blueScore=0;
  updateScore();
  delay(2000);
}

void updateScore(){
  
  Serial.println("update score");
  digitalWrite(BUZZPIN,HIGH);
  delay(1000);
  digitalWrite(BUZZPIN,LOW);
  scoreCard = String(redScore/10) + String(redScore%10) + String(blueScore/10) + String(blueScore%10);
  display.showNumberDecEx(scoreCard.toInt(), 0b01000000, true, 4, 0);
  
}

Credits

Mithun Das

Mithun Das

33 projects • 170 followers
Hacker and Maker driven by passion. Ambassador at Edge Impulse and Balena. Follow me on Twitter @_mithundas

Comments