Code for Scoreboards

Microsoft's MakeCode platform for easy blocks-style programming

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Audentes
 
Posts: 11
Joined: Wed Feb 25, 2015 7:01 pm

Re: Code for Scoreboards

Post by Audentes »

The original function of coin counting I do not know. It was just a thought I had on making it display more than 5 coins, binary style as you stated. Gary might know as he is a player of Shufleboard for the last 20 years.

Your Game Over analysis is correct, when either gets enough points to satisfy the score requirement.

Yes, I think the game select button should cycle around in case someone accidentally presses it one time too many.

Yes, that photo threw me on the button wiring.

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

This scoreboard is 2qtrs. for 15 pt game. 4 for 21 pt game, 5 for 31pt game, 6 for 41 pt game and 7 for 51 pt game. If you can do that it would be great. The scoreboard you are working on now is not showing the 51 point Horse Collar lights, but those are the games played. If that is an issue for this, let me or Dan know. Like I said he can understand you way better.

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Code for Scoreboards

Post by kcl1s »

How do we choose the games that do not have indicators? We could just go on quarters entered or button presses but players may forget what game they are playing. That also does not allow for the storing of extra coins for future games and subtraction your brother talked about. I thought we were going Dan's way and changed the code last night to reflect that. I think I will hold on code work until you guys can nail down exactly what you want on this first board.

Keith

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

What Dan said is perfect. People toss gutters for playing the winner or next game. People dot not drop in extra quarters in the coin box.

User avatar
Audentes
 
Posts: 11
Joined: Wed Feb 25, 2015 7:01 pm

Re: Code for Scoreboards

Post by Audentes »

kcl1s wrote:How do we choose the games that do not have indicators?
Keith
I am not familiar with the other board that Gary has mentioned. I saw a photo of it once, but do not recall if it has an indicator for which game is being played. I think Gary should make the call on this.

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Code for Scoreboards

Post by kcl1s »

GaryTD wrote:What Dan said is perfect. People toss gutters for playing the winner or next game. People dot not drop in extra quarters in the coin box.
Sorry I am getting more confused all the time. This is what Dan said...

So, let's say 15 coins are inserted. That's all 5 coin lights on. we select a game that uses 4 coins so the program will then only illuminate Coin LED's 5, 4 and 2, to indicate 11 remaining coins. Not necessary, but I thought it would be something extra to make it a bit more fun.
Sounds like 2 different things to me. I just want to give you the code that makes you happy.

Here is the 2 views the way I see it.
1. Count coins and play the highest game the coins will allow. No extra game select switch.
2. Count coins up to 15 using all digits to show number entered. Add extra switch to cycle through game choices available for coin count. Subtract coins from total based on game choice.

Both are doable but not at the same time.

Let me know what you decide.

Keith

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Code for Scoreboards

Post by kcl1s »

Audentes wrote:
kcl1s wrote:How do we choose the games that do not have indicators?
Keith
I am not familiar with the other board that Gary has mentioned. I saw a photo of it once, but do not recall if it has an indicator for which game is being played. I think Gary should make the call on this.
I suggest starting with the 15, 21, 51 point games listed. Down the road maybe the code can be tweaked to include others somehow.

It is best to get the basic functions working the way you want first. It will make troubleshooting the code long distance easier.

Keith

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

15, 21 and 51 are fine. People never put quarters in above what is necessary. 2 quarters, the game will play to 15. I am not sure if you can write the code so it lights the green 10 and 5 up showing a 15 point game is ready to play. 4 quarters it lights up the 20 and 1. Not really necessary though. People that play the game know as soon as you drop 2 quarters in the coin slot the score resets to zero and is ready to play. Same with 21 point and 51 point games. I was talking about Dan's comment about lighting up the 5 and 2 on coins dropped for the 51 point game. That get us all in line? :) What else do i need to inform you on? I know I did not explain the game and scoreboard functions too well.
Gary

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

Score resets to nothing on these board, but basically zero in mind I guess. If I did not explain myself it can be 2 quarters in, the 2 lights up, it will how ever you do it reset the game to zero. 21 can be four coins and the game resets to zero but the scoreboard only shows 4 coins inserted. Hope that sounds better. 51 I suppose the 5 an 2 light up for coins inserted and it is ready for play. as simple as can be for now. You are doing o much for me I appreciate it.

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Code for Scoreboards

Post by kcl1s »

I am not sure if you can write the code so it lights the green 10 and 5
Is this the board we are still working on? Where are the green numbers?
[img]
download/file.php?id=65304
[/img]

Keith

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

It was from previos conversations. I believe talk was about how people know which game is being played. 2 quarters and the 5 and 10 would light up. They would know that way for sure. Maybe something for the future.

User avatar
Audentes
 
Posts: 11
Joined: Wed Feb 25, 2015 7:01 pm

Re: Code for Scoreboards

Post by Audentes »

I think Gary was meaning to say make the numbers display in Green, briefly.

I think we should just work on the basics for the "World Map" board first. After that is working then we can talk about custom mods and a software version for the other display. I think they will need to be kept separate to make downloading to the Uno boards simpler.

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

I can not complicate things? :)

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Code for Scoreboards

Post by kcl1s »

It is all good.

I have the code mostly done. I have to setup and label a strip of neopixels to do some testing.

In the mean time I have some testing code to check your wiring.

This one is an all on pixel test. I have reduced the pixel brightness to limit the current. Remember to power the Neopixels from the 5v on the vin pin NOT 5v Arduino pin. The 5v Arduino pin goes through the regulator and can not handle that much current. Use the 5v wall supply not just usb. Pixel pin is pin 6.

Code: Select all

//All On
#include <Adafruit_NeoPixel.h>

#define PIN 6
#define NUMPIXELS 50
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'
  for (uint16_t i = 0; i < pixels.numPixels(); i++) {
    pixels.setPixelColor(i, 50, 50, 50);    //make them dim to limit current draw
  }
  pixels.show();
}

void loop() {
}
This code is a single step through all the pixels one at a time (one on each side) to verify pixel order compared to the list for this board. Each pixel stays on for one second.

Code: Select all

//One at a time
#include <Adafruit_NeoPixel.h>

#define PIN 6
#define NUMPIXELS 51 //one more than pixels for loop control
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pixels.begin();
  pixels.show(); // Initialize all pixels to 'off'
}

void loop() {
  for (uint16_t i = 0; i < pixels.numPixels(); i++) {
    pixels.setPixelColor(i, 120, 120, 120);
    pixels.setPixelColor(i - 1, 0, 0, 0);
    pixels.show();
    delay(1000);
  }

}

This code tests the buttons. You will need to have the usb cable hooked up so you can display the presses on the serial monitor. (hour glass on the upper right of the IDE) Make sure the baud rate is set to 9600 on the drop down on the lower right of the serial monitor. I have the coin / credit on pin 2, the red points on pin 3 and the blue points on pin 4.

Code: Select all

//button test. Use serial monitor
const byte btns[3] = {2, 3, 4}; //Button pins - coin credit, red score, blue score

bool btnState[3] = {HIGH, HIGH, HIGH};
bool oldState[3] = {HIGH, HIGH, HIGH};
bool newPress[3] = {false, false, false};


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  for (int i = 0; i < 3; i++) {
    pinMode(btns[i], INPUT_PULLUP);
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  btnCheck();
  if (newPress[0]) Serial.println("Coin / Credit");
  if (newPress[1]) Serial.println("Red Point");
  if (newPress[2]) Serial.println("Blue Point");
  delay(50);
}

void btnCheck() {
  for (int i = 0; i < 3; i++) {
    newPress[i] = false;
    btnState[i] = digitalRead(btns[i]);
    if ((btnState[i] == LOW) && (oldState[i] == HIGH)) {
      newPress[i] = true;
    }
    oldState[i] = btnState[i];
  }
  delay(50);
}
Let me know how you make out.
Keith
Last edited by kcl1s on Thu Mar 07, 2019 11:08 pm, edited 1 time in total.

User avatar
GaryTD
 
Posts: 59
Joined: Fri Feb 22, 2019 12:26 pm

Re: Code for Scoreboards

Post by GaryTD »

I will have my brother look at this. I am getting parts tomorrow and will set it up, let you know after that.
Thanks

Locked
Please be positive and constructive with your questions and comments.

Return to “MakeCode”