Skeeball scoring hardware and program

Hello all!

I have decided that I wanted to build a skeeball game for use at home. The idea popped into my head one day, and I decided to Google a bit and see what's already been done. Lo and behold there are several FANTASTIC skeeball game builds in various corners of the web.

The particular one I want to build is designed in such a way that it will be easy to score manually. The balls will be funneled into return chutes that correspond with whichever hole on the target board they go through, so simply add up the points when they roll down to the playing position.

However, I thought it would be really cool to try and design an automatic electronic scoring system and a scoreboard. Several of the builds I found did this, but they just barely touched on that side of the build. They focused mostly on the carpentry aspect of the build. Which is good, as without that I won't have a game at all.

I DID find ONE lone build where the builder covered, in great detail, his design, build, and program on his automatic scoring system. He gave a few links to his various parts chosen, showed good pictures, and even attached his code for us to see. This was the spark that I needed to motivate me to try to learn to use an Arduino. I've known about them for years, but I've never thought I had a need for one enough to try it out. I also assumed I probably couldn't learn to program it. The build I followed for the scoreboard is an Instructable on the Instructables website. I'd be happy to attach a link, but I don't think I'm supposed to.

I started a Python 3 course, and shortly after realized that C++ is more different than Python than I thought (someone had me under the impression that they are basically the same). So, for now, I have paused that course and I'm working my way through "Arduino For Dummies." It seems like a good resource so far.

FGYYLOZKCNDLZCB (1).jpg

Essentially, you roll 9 balls. Press a reset button to start the game. There are holes in the board scored 10, 20, 30, 40, 50, and 2 100 point holes. I'd like to have an led light corresponding to the most recent hole scored that lights up designating 10 or 30 or 100, etc. I'd like it to have one screen that tracks number of balls played, and for it to report game over after ball 9. After ball 9 the reset button should clear everything to 0. Some games traditionally give the 9th ball rolled a double score, which is what the "redball" is for.

He used an Arduino Mega for this task, and I would like to do the same.

He also used

· LED lights (for scoreboard)
· 2.3” single digit 7-segment LED (E-Bay)
· 1.2” tall, 4-digit, 7-segment LED (Adafruit Industries)
· Various solder boards
· 220 ohm resistors (for LED lights and tall 7-segment LED)
· Momentary switch (reset switch)
· Servo motor (drop down door for game ball release)

I don't plan to use a ball drop mechanism, so I do not need the servo motor. I'll need to edit that out of the code.

I have not yet purchased any of the hardware, but perhaps after Christmas I want to start ordering what I need and start seeing if I can get this to work on the bench.

FGYYLOZKCNDLZCB (1).jpg

I see no mention of any hardware that would sense which hole a ball went into or how many balls had been played.

I'd be happy to attach a link, but I don't think I'm supposed to.

Why wouldn't you be able to post a link. We cannot help with code that we cannot see.

Do you have specific questions? "How do I make a Skeeball machine with Arduino?" is a bit too general.

// File = Skeeballgolfball5.ino
//**************************************************************
// 1/20/2020 Covert to basic 1-player after wrote 2-player version
// 1/26/2020 Added 100 point light
// 4/17/2020 Start modify to golfball size game.
// Used internal resistors on all switches (Push = LOW).
// 4/23/2020 Got single large 7-segment LED working (# of balls)
// 5/1/2020 Added LED light for each point hole (match LED in hole)
// 5/4/2020 Almost completed code, adapted well from oneplayerskeeball
// Added servo for drop down release of balls for new game.
// 5/2/2020 - Start building score board for top of machine.
//***************************************************************
#include // Enable this line if using Arduino Uno, Mega, etc.
#include
#include "Adafruit_LEDBackpack.h"
Adafruit_7segment matrix = Adafruit_7segment();
#include
#include
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
//==============================Declare Servo======================
#include
int servoPin = 12;
Servo Servo1;
//=================================================================
int switch10Pin = 43;
int switch20Pin = 45;
int switch30Pin = 47;
int switch40Pin = 49;
int switch50Pin = 51;
int switch100Pin = 53;
int switchresetPin = 9;
int button10State = 1;
int button20State = 1;
int button30State = 1;
int button40State = 1;
int button50State = 1;
int button100State = 1;
int buttonresetState = 1;
int totalscore;
int noballs;
int redball;
//============================Large 7-segment=================================
byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
{ 1,1,1,1,0,0,1 }, // = 3
{ 0,1,1,0,0,1,1 }, // = 4
{ 1,0,1,1,0,1,1 }, // = 5
{ 1,0,1,1,1,1,1 }, // = 6
{ 1,1,1,0,0,0,0 }, // = 7
{ 1,1,1,1,1,1,1 }, // = 8
{ 1,1,1,0,0,1,1 } // = 9
};
void sevenSegWrite(byte digit) {
byte pin = 2;
for (byte segCount = 0; segCount //10
pinMode(33, OUTPUT); //20
pinMode(35, OUTPUT); //30
pinMode(37, OUTPUT); //40
pinMode(39, OUTPUT); //50
pinMode(41, OUTPUT); //100
pinMode(A1, OUTPUT); //=== Game over LED
pinMode(A0, OUTPUT); //=== Red Ball next LED
pinMode(A2, OUTPUT); //=== New Game LED
//=========================================================
//==============================Use internal resistor============
pinMode(switch10Pin, INPUT_PULLUP);
pinMode(switch20Pin, INPUT_PULLUP);
pinMode(switch30Pin, INPUT_PULLUP);
pinMode(switch40Pin, INPUT_PULLUP);
pinMode(switch50Pin, INPUT_PULLUP);
pinMode(switch100Pin, INPUT_PULLUP);
pinMode(switchresetPin, INPUT_PULLUP);
//===============================================================
matrix.begin(0x70);
noballs = 0;
totalscore = 0;
redball = 1;
lcd.begin(20,4);
lcd.setCursor(3,0);
lcd.print("New Game!");
matrix.print(0);
matrix.writeDisplay();
//======================================== 7-segment single digit====
sevenSegWrite(0);
//===================================================================
}
void loop()
{
button10State = digitalRead(switch10Pin);
button20State = digitalRead(switch20Pin);
button30State = digitalRead(switch30Pin);
button40State = digitalRead(switch40Pin);
button50State = digitalRead(switch50Pin);
button100State = digitalRead(switch100Pin);
buttonresetState = digitalRead(switchresetPin);
//============================================= Check which button pushed above
if (buttonresetState == LOW)
{
totalscore = 0;
noballs = 0;
redball = 1;
digitalWrite(A1, LOW); //==Game Over LED
digitalWrite(A0, LOW); //==Red Ball LED
controlscoreled(48); //==Dummy pin-all point LEDs off
lcd.begin(20,4);
lcd.setCursor(3,0);
lcd.print(" New Game!");
matrix.clear();
matrix.print(0);
matrix.writeDisplay();
//======================================== 7-segment single digit====
sevenSegWrite(0);
//===================================================================
//===================================Drop door for balls=============
Servo1.write(90);
for (int i = 0, i //loop
//==============================================================

Attached is the code that he used. I'm hoping to be able to use it at least as a base for what I want to do. I suspect if I get my pin choices and hardware right I could possibly almost directly use this.

He also built another game that was a golf/skeeball hybrid. The code above is a modification of the code from that original golf game, hence the reference in the first couple of lines of code. I do have access to that code as well.

Do you all see any glaring issues with the code? The library portions near the top confuse me. It seems to '#include' nothing at all. I'm guessing, though, as long as I download the appropriate libraries for the hardware that I choose, and include those, I shouldn't fret over that too much?

Also, the sections that deal with the servo motor, I'm thinking I can just turn them into comments but not totally delete them. Correct? Perhaps in the future I may want to come up with a ball drop. It IS a rather satisfying noise when those balls roll down and clink together.

groundFungus:
I see no mention of any hardware that would sense which hole a ball went into or how many balls had been played.
Why wouldn't you be able to post a link.

I'm sorry. I forgot to attach the sensor that I will use for that. These are what most use. Some use beam break sensors which arare more reliable for this task, but they are not as simple to use. It's a 5 v sensor.

The Sticky for getting the most out of the forum warns not to link to other forums. I'm not sure where Instructables falls on that spectrum.

The Sticky for getting the most out of the forum warns not to link to other forums

I do not know where it says that. Can you point it out? I am sure that you are misinterpreting what it says. People link to other sites all the time and it is often necessary in order for us to help.

There is a lot missing from the code that you posted. A lot of blank includes, no setup() function and poor indenting at least. And the code is incomplete.

So post a link so that we can see the whole project.

Will do!

In step 9 he links a download to his code. Perhaps a direct download of the file and opening it in the right program would be better. Or maybe something is wrong with the file he posted in that tutorial.

I cannot see the download, however, until I log in to my Instructable account. If I follow the link to it without logging in that part seems hidden. I also have it on my Google Drive.

This is the code to his original golf skee game. He modified this to create the code for the skee ball game that I home to replicate. Does this have the same issues? Not that it will help me as much.

Here's the code for that one. 

/* 
  File name : ExecutiveGolf9.ino
  9/4/2020 - Start Executive Par 3 Code
  9/8/2020 - it worked, tested over the weekend, cleaning up
             some things displayed on LCD
  9/9/2020 - Added function to control scoring LEDs and game
             start
  9/10/2020 - Didn't work with analog pins - maybe because declared
              variable as interger. Worked on digital pins
              Will use mega arduino for more pins
  9/10/2020 - added button for 1 vs. 2 player game. Got rid of
              manual inning button left from BagsBaseball
            =========== means new today - tried just the "Ace"
              hole and the code seemed to work
  9/11/2020 - converted all scoring to 2 player option
  9/15/2020 - add 2 player LED when button pushed
            - single player game is going on 1 too many turns
  9/16/2020 - didn't work, single player game ending at 8
  9/17/2020 - changed last if statement to 20 - it worked
  10/2/2020 - add Double Bogey button when ball in net or on "water"
              or off playing surface. Score of 5.
            - Changed ace and birdie to see if displays sync
              better
  10/6/2020 - Cleaned up some code for 1-player game
*/


#include <Wire.h> 
#include <Adafruit_GFX.h> 
#include "Adafruit_LEDBackpack.h" 
 
Adafruit_7segment matrix1 = Adafruit_7segment(); 
Adafruit_7segment matrix2 = Adafruit_7segment(); 

#include<Wire.h>
#include<LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

#define SENSORPIN1 9
#define SENSORPIN2 10
#define SENSORPIN3 11
#define SENSORPIN4 12

#define SENSORPIN5 35        //---Add Double Bogey button

#define BUTTONPINreset A0    //---Reset, cancel, new game
#define BUTTONPINatbat A1    //---Now 1 vs 2 player

int sensorState1 = 0; 
int sensorState2 = 0; 
int sensorState3 = 0; 
int sensorState4 = 0; 

int sensorState5 = 0;       //---Add Double Bogey button

int sensorStatereset = 0; 
int sensorStateatbat = 0; 
     
int totalscore1;
int totalscore2;

int atbat;
int inn;
int homeaway;

int noplayer;      //========= added for 1 vs. 2 player game

//============================Large 7-segment=================================
byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 },  // = 0
                                                    { 0,1,1,0,0,0,0 },  // = 1
                                                    { 1,1,0,1,1,0,1 },  // = 2
                                                    { 1,1,1,1,0,0,1 },  // = 3
                                                    { 0,1,1,0,0,1,1 },  // = 4
                                                    { 1,0,1,1,0,1,1 },  // = 5
                                                    { 1,0,1,1,1,1,1 },  // = 6
                                                    { 1,1,1,0,0,0,0 },  // = 7
                                                    { 1,1,1,1,1,1,1 },  // = 8
                                                    { 1,1,1,0,0,1,1 }   // = 9
                                                    };

 void sevenSegWrite(byte digit) {
  byte pin = 2;
  for (byte segCount = 0; segCount < 7; ++segCount) {
    digitalWrite(pin, seven_seg_digits[digit][segCount]);
    ++pin;
  }
}
//========================================================================

//==============================Function to turn on/off score LEDs & Start

int controlscoreled(int pinnum){       
  digitalWrite(22, LOW);      // -- Ace
  digitalWrite(24, LOW);      // -- Birdie
  digitalWrite(26, LOW);      // -- Par
  digitalWrite(28, LOW);      // -- Bogey  
  digitalWrite(13, LOW);     // -- Green light - start new game and keep on
                             // -- Once 9 holes it goes off - game over

  digitalWrite(pinnum, HIGH);
}
//========================================================================


void setup() {
  
//====================Set pins for Single 7-segment number
  pinMode(2, OUTPUT);   
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
//============================================

//======================= Hole Value LED Light and Start===
//*****Need to fill in new pin numbers when get Mega board
  pinMode(22, OUTPUT);   //--Ace
  pinMode(24, OUTPUT);   //--Birdie
  pinMode(26, OUTPUT);   //--Par
  pinMode(28, OUTPUT);   //--Bogey
  pinMode(13, OUTPUT);   //=== New Game LED
  pinMode(30, OUTPUT);   //=== 2-player indicator, 9/15/2020
//=========================================================
  

  pinMode(SENSORPIN1, INPUT_PULLUP); 
  pinMode(SENSORPIN2, INPUT_PULLUP); 
  pinMode(SENSORPIN3, INPUT_PULLUP); 
  pinMode(SENSORPIN4, INPUT_PULLUP); 

  pinMode(SENSORPIN5, INPUT_PULLUP);    //---Add Double Bogey button

  pinMode(BUTTONPINreset, INPUT_PULLUP); 
  pinMode(BUTTONPINatbat, INPUT_PULLUP); 
  
  digitalWrite(SENSORPIN1, HIGH);         // turn on the pullups
  digitalWrite(SENSORPIN2, HIGH); 
  digitalWrite(SENSORPIN3, HIGH); 
  digit

The code from the Instructable downloaded fine for me and seems complete. I attached the code that I downloaded because it is too big for code tags.

What are your questions, specifically?

Skeeballgolfball5 .ino (8.85 KB)

groundFungus:
The code from the Instructable downloaded fine for me and seems complete. I attached the code that I downloaded because it is too big for code tags.

What are your questions, specifically?

Awesome. Thank you!
I don't have a way to open that file, I'm using a mobile device right now. I requested for it to be sent to me as text that I could review. Something must have happened in that process. I'll find a way to get it open correctly so I can review it and try to pick it apart.
I think you've answered most of my questions. The incomplete #include lines were puzzling to me. I was trying to work out what to do with that.
I also want to deactivate the portions of code that should control the servo motor. If I can't, i CAN add a motor and just leave it in place as a dummy, but that seems silly when I know it's not necessary.
Since this was written to do exactly what I'm hoping to accomplish, I wanted to try to work backwards through it to make it work for me here on this project. I want to order my hardware and start working on getting it going on the bench.
I need to find a way to get this program open so I can read the code and look through it written properly. I hope to get a good overview of the process, which I think I have, then work on understanding the specific functions used.

I found an app that lets me open .ino files on Android. Got it open for review!

I have a question now. I have been working on compiling an order for my hardware today. After that I decided to try to work out which pins each item will need to be wired to. That's where I've gotten confused.

The 1.2" 4 digit 7 segment display from ADAFruit has a backpack, and only requires two pins to run. The builder on the Instructable stated he used the SDA pin and SCL pin to control it. I don't see that declared in the program anywhere. I don't know what to make of that.

The other single digit 7 segment display requires 7 pins and I see them declared as 2, 3, 4, 5, 6, 7, and 8. Is that correct?

I also have the pins for my microswitches as follows:

10 point switch is pin 43
20 point switch. 45
30 point switch. 47
40 point switch. 49
50 point switch. 51
100 point switch. 53

My score LEDs are

10 point is pin 31
20 point. 33
30 point. 35
40 point. 37
50 point. 39
100 point 41

Reset switch is pin 9

Servo is pin 12

Game over led is pin A1

New game led is pin A2

Redball led is pin A0

Does it seem that I've interpreted all of that correctly?

groundFungus:
The code from the Instructable downloaded fine for me and seems complete. I attached the code that I downloaded because it is too big for code tags.

What are your questions, specifically?

well it doesn't work for me, I think that I miss the specific file/extractor

I've been able to download it and open it on an Android app that will open and display .ino files, but I have no idea if it will open and run on an Arduino as is.

I downloaded the file to Notepad++. Then copy-pasted to the Arduino IDE. I do it that way so that there is no folder created on my system for a file that I will never use but do want to examine.

There is an error in the "flicker light" for loop. The commas in the for statement need to be replaced with semicolons.

I would also replace the LiquidCrystal_I2C library with the hd44780 library for I2C LCDs. It is hard to know which particular LiquidCrystal_I2C library to install as there are several incompatible versions with the same name. And the hd44780 library is just a better, faster library.

Thanks so much!

I actually don't even know if I'll use the LCD screen to test it out. I've ordered everything so I may just mock it all up as it should be when it's finished and test it out like that.

But, I've ordered the LCD anyway. I suspect this won't be my last project with an Arduino, so I have no doubt it will be useful some time or another.

It'd be best if that part of the code works anyway.

Once I finish this project up I hope to create my own detailed thread on a couple of forums and Instructables with links to any necessary code. So for that reason also it'll be best if it all works.

Here's the particular game I want to build, but with the addition of an electronic scoreboard.

This will go in what will be a game area in the attic. The only thing currently there is my old Nintendo with Duck Hunt

FFJ2AVJJ7MFE1QC.jpg

FJSZQJ2J7MFE23Y.jpg

Once I learn how to manipulate this code well enough, do you guys see any reason I won't be able to use this to control with the arduino? According to the description there is a 5v version, but with the Chinglish I'm wary. I think it would be cool to write a piece of code to make a strobe light and buzzer go off if someone rolls a perfect game (i.e. final score=1000)