Components and supplies
Cutting board translucent plastic
cutting board
Linear Regulator (7805)
capacitors
small pushbutton (generic)
5m/roll DC5V ws2812b 300led Individually Addressable 60leds/m 5050 RGB
Cutting board flexible grey
Arduino UNO
large pushbutton switch
Peg Board
Digital LED strip 5 m WS2811 with 5050 Leds
Audio cable
Resistor 221 ohm
Tools and machines
Common Tools & Test equipment
Project description
Code
BINGO_Machine_rev04.ino
arduino
Sketch for BINGO Machine with Arduino Uno and 2 A4 sized 7-Segment Displays with an Electronic Score Board
1/* 2 This is the code for a Bingo Machine developed and produced by Pierre Pennings (November 2018) 3 The machine uses 2 DIGIT large A4 sized 7-Segment displays made with WS2811 LED strip powered with 12V (pairs of 3 LEDs with 1 control chip) 4 Each segment consisting of 3 LEDs is adressed with just one control adress 5 Each display has 7 segments plus a decimal point (DP) 6 The numbers presented on the 2 displays run from 1 to 75, just like in a normal BINGO game 7 A momentary push button is connected to GND and to digital IO pin 6 of an ARDUINO UNO 8 Pushing the button starts the generation of a New random Number 9 After a short "Light Show 1" the random number is shown on the two 7-Segment displays 10 The generated Number is also stored in an Array called SCORE[] consisting of 75 positions either filled with "0" or "1" 11 If the generated New Number allready exist, automatically a new random number is generated 12 All electronics including the ARDUINO UNO itself have been built in a separate Score Board Display 13 The 75 numbers are lit with one WS2812B controller chips with one SMD5050 LED each (powered with 5 V) 14 The Score Board shows all the random numbers generated until a valid BINGO is achieved 15 A push button called "BINGO" will end the round with a short "BingoLightShow" 16 Hereafter the SCORE array is cleared and a new round can be started 17 A New Round can also be started by toggeling the power switch (disconnecting the 12V power) which will RESET the ARDUINO and restart the programme 18 A 12V, 2A charger supplies the power to the complete BINGO machine 19 The 12 V input on the ARDUINO power jack has been modified to enable power switching (on - off) 20 The 5 V power for the 99 LEDs (75 + 24) used for the Score Board is derived from the 12V input power by means of a 7805 voltage regulator 21 (which can nearly handle the current drawn by the WS2812 LED strip); installing a Heatsink or a power version is recommended 22 23 This code is licensed under GPL3+ license. 24*/ 25 26#include <Adafruit_NeoPixel.h> 27 28const int NewnumberButton = 2 ; // Digital IO pin 2 is connected to the Newnumber button with a normally open contact 29// Pin 2 will be driven with the built-in pull-up resistor to make it normally HIGH 30// The switch will pull the pin to ground momentarily. 31// On a high -> low transition by pushing the button the programme will generate a New Number. 32 33const int BingoButton = 4 ; // Digital IO pin 4 is connected to the BINGO button with a normally open contact 34// Pin 4 will be driven with the built-in pull-up resistor to make it normally HIGH 35// The BINGO Button will pull the pin to ground 36// On a high -> low transition by pushing the BINGO button a Lightshow will start and thereafter the programme will end. 37 38const int LedPin = 6 ; // Digital IO pin 6 connected to the Data In (DI) of the WS 2811 LED strips via a 220 Ohm resistor 39 40int Newnumber = 1; 41int Bingo = 1; 42 43int SCORE[76]; 44int count = 0; 45long randNumber; 46int NUMBER = 0; 47int NW_NUMBER = 0; 48int TENSNUMBER = 0; 49int UNITNUMBER = 0; 50 51 52#define NUM_LEDS 99 // the first 16 are used to control (WS 2811) the LED's in the 2 digit 7-segment displays 53//(two times 8 segments on the two displays); number 0 -7 are for the UNIT number 54// Number 8 - 15 are for the TENS number ( number 7 and 15 are the DPs of each DIGIT) 55// for displaying the numbers on the Score Board Display and controlling the (WS2812) LEDS the adresses 16 upto 99 are used 56// 24 LEDs are used for backlighting the letters BINGO and 75 for the score board to enable the display of the generated BINGO numbers; 57// all of the LEDs will be controlled with just one wire! from LED_PIN 6 58// as a matter of fact two different types of LED strip are controlled (in parralel)from the same LedPin 6 via two 220 Ohm resistors 59 60#define BRIGHTNESS 250 // sets the brightness of the LEDs to allmost maximum (255) 61 62Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LedPin, NEO_GRB + NEO_KHZ800); 63 64/*2-dimensional array with NUMBER to segment allocations, each NUMBER has its own colum---------------------------------------------------- 65 8 0 66 13 9 5 1 67 14 6 68 12 10 4 2 69 11 15 3 7 70 71 Digit 2 Digit 1 72 Tens Units 73 7 and 15 represent the Decimal Points (DP) 74*/ 75 76// 0 1 2 3 4 5 6 7 8 9 77byte SEGMENTarray [8][10] = { {1,0,1,1,0,1,1,1,1,1,}, //segment 0 or 8 78 {1,1,1,1,1,0,0,1,1,1,}, //segment 1 or 9 79 {1,1,0,1,1,1,1,1,1,1,}, //segment 2 or 10 80 {1,0,1,1,0,1,1,0,1,1,}, //segment 3 or 11 81 {1,0,1,0,0,0,1,0,1,0,}, //segment 4 or 12 82 {1,0,0,0,1,1,1,0,1,1,}, //segment 5 or 13 83 {0,0,1,1,1,1,1,0,1,1,}, //segment 6 or 14 84 {0,0,0,0,0,0,0,0,0,0,}, //segment 7 or 15 85 }; 86 87byte color_scheme[] = { 88 50, 100, 200, 89 100, 150, 250, 90 150, 200, 50, 91 200, 250, 100, 92 250, 50, 150, 93 0, 100, 200, 94 50, 150, 250, 95 100, 200, 0, 96 150, 250, 50, 97 200, 0, 100, 98 250, 50, 200, 99 0, 100, 250, 100 50, 150, 0, 101 250, 0, 0 102}; 103 104/////////////////////////////////////////////////// the setup code that follows, will run once after "Power On" or after a RESET 105void setup() { 106 Serial.begin(9600); 107 pinMode(LedPin, OUTPUT); // initialize the LedPin 6 as an output: 108 pinMode(NewnumberButton, INPUT_PULLUP); // initialize the pushbutton pin 2 as an input: 109 pinMode(BingoButton, INPUT_PULLUP); // initialize the bingobutton pin 4 as an input: 110 111 strip.setBrightness(BRIGHTNESS); 112 strip.begin(); // Initialize all LEDs to "off" 113 strip.show(); 114 115 for (int t = 16; t < 24 ; t++) 116 { 117 strip.setPixelColor(t, 0, 0, 250); // After Power On show the word BINGO on the Score Board with Blue characters 118 strip.show(); // note that the order of colors of the WS2812 LED strip is R,G,B 119 } 120 121 for (count = 0; count < 76 ; count++) { // put all data in the Array SCORE to 0 (Array positions run from 0 to 75; the zero position is not used) 122 SCORE[count] = 0; 123 } 124 125 /*for (int n = 0; n < 10 ; n++) // this code can be used for testing all the numbers from 0 - 9 on the two 7-Segment displays (the 2 DP's are not tested) 126 { 127 for (int s = 0; s < 8 ; s++) 128 { 129 int z = SEGMENTarray [s][n]; 130 int i = 0 + s; int j = 8 + s; 131 strip.setPixelColor(i, z*250, 0, z*50); 132 strip.setPixelColor(j, z*250, 0, z*50); 133 strip.show(); 134 135 Serial.print("["); Serial.print(n); Serial.print("]"); Serial.print("["); Serial.print(s); Serial.print("] = ");Serial.print(z); Serial.print(" "); 136 } 137 delay (1500); 138 Serial.println(); 139 } 140*/ 141 142} 143 144/////////////////////////////////////////////////// the loop code that follows, will run repeatedly until "Power Off" or a RESET 145void loop() { 146 Newnumber = digitalRead(NewnumberButton); 147 148 if (Newnumber == LOW) // no need for a Short delay to eliminate bouncing effects of the button because at first LOW the loop proceeds 149 { 150 randomSeed(millis()); 151 do { 152 GENERATENEWNUMBER (75); // generate a NW_NUMBER between in the range from 1 to 75 153 } // if the NW_NUMBER allready exists: generate again a NW_NUMBER 154 while (NW_NUMBER == SCORE[NW_NUMBER] * NW_NUMBER); 155 156 SCORE[NW_NUMBER] = 1; // put a 1 in the Array at the NW_NUMBER position 157 NUMBER = NW_NUMBER; 158 TENSNUMBER = int (NUMBER / 10); // calculate the decimal value of the NW_NUMBER and the unit value 159 UNITNUMBER = NW_NUMBER - (10 * TENSNUMBER); 160 161 CLEARDISPLAY (); 162 LIGHTSHOW1 (4, 100); // start lightshow1 163 CLEARDISPLAY (); 164 165 //PRINTNUMBERSERIAL(); // print the generated NW_NUMBER to the serial monitor and show the new content of the SCORE array 166 167 DISPLAYNUMBER (TENSNUMBER, UNITNUMBER); 168 169 DISPLAYSCORE (); 170 171 } 172 else { 173 Bingo = digitalRead(BingoButton); 174 if (Bingo == LOW) 175 delay (3000); // a delay of 3 second to eliminate bouncing effects and accidental pushing of the button because 176 if (Bingo == LOW) 177 { 178 BINGOLIGHTSHOW (); 179 for (count = 0; count < 76 ; count++) // put all data in the Array SCORE back to 0 and a new BINGO round can be started 180 { 181 SCORE[count] = 0; 182 } 183 } 184 } 185} 186//////////////////END of LOOP//////////////////////////////////////////////////////////// 187 188 189/////////////////////////////////////////////////// Hereafter follow the specific Functions that are called from within the loop 190void LIGHTSHOW1 (int duration, uint8_t wait) { 191 192for (int t = 16; t < 24 ; t++) 193 { 194 strip.setPixelColor(t, 0, 0, 0); // turn off the BINGO Leds with Blue characters as put upon set up 195 strip.show(); 196 } 197 198 for (int k = 0; k < duration; k++) 199 { // flash the DP leds in a white color 200 strip.setPixelColor(7, 200, 200, 200); 201 strip.show(); 202 delay(wait); 203 strip.setPixelColor(7, 0, 0, 0); 204 strip.setPixelColor(15, 200, 200, 200); 205 strip.show(); 206 delay(wait); 207 strip.setPixelColor(15, 0, 0, 0); 208 } 209 210 int redVal, blueVal, greenVal; 211 for (int k = 1; k < 45 ; k = k + 3) 212 { // run a rainbow color lightshow with colors defined in the Array color_scheme 213 redVal = color_scheme[k]; 214 blueVal = color_scheme[k + 1]; 215 greenVal = color_scheme[k + 2]; 216 217 for (int p = 0; p < 7; p++) 218 { // the collors of the WS2811 strip are adressed in the order R, B, G 219 int i = 0 + p; int j = 8 + p; 220 strip.setPixelColor(i, strip.Color(redVal, blueVal, greenVal) ); 221 strip.setPixelColor(j, strip.Color(greenVal, redVal, blueVal ) ); 222 strip.show(); 223 delay(30); 224 } 225 } 226 227 for (int q = 0; q < 7 ; q++) 228 { // put all segments of the 7-segment displays to "off" 229 int i = 0 + q; int j = 8 + q; 230 strip.setPixelColor(i, 0, 0, 0); 231 strip.setPixelColor(j, 0, 0, 0); 232 strip.show(); 233 } 234} 235 236/////////////////////////////////////////////////Hereafter follows the function for generating the BINGO LIGHTSHOW after the Bingo Button is pushed 237void BINGOLIGHTSHOW () { 238 239for (int l = 0; l<10; l++) 240 { 241 for (int k = 24; k < 39 ; k++) // present a waterfall of white leds on the SCORE board 242 { 243 strip.setPixelColor(k, 200, 200, 200); 244 strip.setPixelColor(k+15, 200, 200, 200); 245 strip.setPixelColor(k+30, 200, 200, 200); 246 strip.setPixelColor(k+45, 200, 200, 200); 247 strip.setPixelColor(k+60, 200, 200, 200); 248 strip.show(); 249 delay(5); 250 strip.setPixelColor(k, 0, 0, 0); 251 strip.setPixelColor(k+15, 0, 0, 0); 252 strip.setPixelColor(k+30, 0, 0, 0); 253 strip.setPixelColor(k+45, 0, 0, 0); 254 strip.setPixelColor(k+60, 0, 0, 0); 255 strip.show(); 256 } 257 258 for (int t = 0; t < 24 ; t++) 259 { 260 strip.setPixelColor(t, 0, 250, 250); // turn on the 7-segment displays and BINGO Leds 261 strip.show(); 262 } 263 delay(50); 264 for (int t = 0; t < 24 ; t++) 265 { 266 strip.setPixelColor(t, 0, 0, 0); // turn off the 7-segment displays and BINGO Leds 267 strip.show(); 268 } 269 } 270} 271 272/////////////////////////////////////////////////// Hereafter follows the function for generating a new number after the New Number Button is pushed 273void GENERATENEWNUMBER (int range) { 274 randNumber = random(1, range + 1); 275 NW_NUMBER = int(randNumber); 276} 277 278/* 279////////////////////////////////////////////////// This function can be used to present the generated NUMBER and show the modified contents of the SCORE array 280void PRINTNUMBERSERIAL () { 281 Serial.print("NUMBER = "); 282 Serial.print(NUMBER); 283 Serial.print(" , TENSNUMBER = "); 284 Serial.print(TENSNUMBER); 285 Serial.print(" , UNITNUMBER = "); 286 Serial.println(UNITNUMBER); 287 count = 1; 288 while (count < 76) 289 { // print all data in the Array SCORE (Array positions from 0 to 75; the zero position remains 0) 290 for (int column = 0; column < 15; column++) 291 { 292 Serial.print("["); Serial.print(count); Serial.print("] = "); Serial.print(SCORE[count]); Serial.print(" "); 293 count++; 294 } 295 Serial.println(""); 296 } 297} 298*/ 299 300///////////////////////////////////////////////// This function is used to display the generated NUMBER on the two 7-Segments displays 301void DISPLAYNUMBER (int TENS, int UNIT) { 302 303 for (int t = 16; t < 24 ; t++) 304 { 305 strip.setPixelColor(t, 200, 0, 0); // turn on the BINGO word Leds in RED characters 306 strip.show(); 307 } 308 309 for (int s = 0; s < 8 ; s++) 310 { // take the data from the SEGMENT array to turn on correct segments for displaying the UNITS and TENS of the NUMBER in RED 311 int t = SEGMENTarray [s][TENS]; 312 int u = SEGMENTarray [s][UNIT]; 313 int i = 0 + s; int j = 8 + s; 314 strip.setPixelColor(i, u*250, 0, 0); 315 if (TENS!=0) { 316 strip.setPixelColor(j, t*250, 0, 0); 317 } 318 else { 319 strip.setPixelColor(j, 0, 0, 0); 320 } 321 strip.show(); 322 } 323} 324 325///////////////////////////////////////////////// This function is used to display the generated NUMBER on the two 7-Segments displays 326void DISPLAYSCORE () { 327 328 for (int t = 16; t < 24 ; t++) 329 { 330 strip.setPixelColor(t, 200, 0, 0); // turn on the BINGO word Leds in RED characters 331 strip.show(); 332 } 333 334 for (int s = 24; s < 100 ; s++) 335 { // turn on the LEDs for the existing Numbers in GREEN 336 int u = SCORE[s-23]; 337 strip.setPixelColor(s, 0, u*200, 0); 338 strip.show(); 339 } 340 strip.setPixelColor((23+NUMBER), 200, 0, 0); // turn on the LEDs for the new Number in RED 341 strip.show(); 342} 343 344///////////////////////////////////////////////// This function is used to clear the two 7-Segments displays 345void CLEARDISPLAY () { 346 347for (int q = 0; q < 7 ; q++) 348 { 349 int i = 0 + q; int j = 8 + q; 350 strip.setPixelColor(i, 0, 0, 0); 351 strip.setPixelColor(j, 0, 0, 0); 352 strip.show(); 353 } 354 355 for (int t = 16; t < 24 ; t++) 356 { 357 strip.setPixelColor(t, 0, 0, 0); // turn off the RED characters of the BINGO word 358 strip.show(); 359 } 360} 361 362
BINGO_Machine_rev04.ino
arduino
Sketch for BINGO Machine with Arduino Uno and 2 A4 sized 7-Segment Displays with an Electronic Score Board
1/* 2 This is the code for a Bingo Machine developed and produced by Pierre Pennings (November 2018) 3 The machine uses 2 DIGIT large A4 sized 7-Segment displays made with WS2811 LED strip powered with 12V (pairs of 3 LEDs with 1 control chip) 4 Each segment consisting of 3 LEDs is adressed with just one control adress 5 Each display has 7 segments plus a decimal point (DP) 6 The numbers presented on the 2 displays run from 1 to 75, just like in a normal BINGO game 7 A momentary push button is connected to GND and to digital IO pin 6 of an ARDUINO UNO 8 Pushing the button starts the generation of a New random Number 9 After a short "Light Show 1" the random number is shown on the two 7-Segment displays 10 The generated Number is also stored in an Array called SCORE[] consisting of 75 positions either filled with "0" or "1" 11 If the generated New Number allready exist, automatically a new random number is generated 12 All electronics including the ARDUINO UNO itself have been built in a separate Score Board Display 13 The 75 numbers are lit with one WS2812B controller chips with one SMD5050 LED each (powered with 5 V) 14 The Score Board shows all the random numbers generated until a valid BINGO is achieved 15 A push button called "BINGO" will end the round with a short "BingoLightShow" 16 Hereafter the SCORE array is cleared and a new round can be started 17 A New Round can also be started by toggeling the power switch (disconnecting the 12V power) which will RESET the ARDUINO and restart the programme 18 A 12V, 2A charger supplies the power to the complete BINGO machine 19 The 12 V input on the ARDUINO power jack has been modified to enable power switching (on - off) 20 The 5 V power for the 99 LEDs (75 + 24) used for the Score Board is derived from the 12V input power by means of a 7805 voltage regulator 21 (which can nearly handle the current drawn by the WS2812 LED strip); installing a Heatsink or a power version is recommended 22 23 This code is licensed under GPL3+ license. 24*/ 25 26#include <Adafruit_NeoPixel.h> 27 28const int NewnumberButton = 2 ; // Digital IO pin 2 is connected to the Newnumber button with a normally open contact 29// Pin 2 will be driven with the built-in pull-up resistor to make it normally HIGH 30// The switch will pull the pin to ground momentarily. 31// On a high -> low transition by pushing the button the programme will generate a New Number. 32 33const int BingoButton = 4 ; // Digital IO pin 4 is connected to the BINGO button with a normally open contact 34// Pin 4 will be driven with the built-in pull-up resistor to make it normally HIGH 35// The BINGO Button will pull the pin to ground 36// On a high -> low transition by pushing the BINGO button a Lightshow will start and thereafter the programme will end. 37 38const int LedPin = 6 ; // Digital IO pin 6 connected to the Data In (DI) of the WS 2811 LED strips via a 220 Ohm resistor 39 40int Newnumber = 1; 41int Bingo = 1; 42 43int SCORE[76]; 44int count = 0; 45long randNumber; 46int NUMBER = 0; 47int NW_NUMBER = 0; 48int TENSNUMBER = 0; 49int UNITNUMBER = 0; 50 51 52#define NUM_LEDS 99 // the first 16 are used to control (WS 2811) the LED's in the 2 digit 7-segment displays 53//(two times 8 segments on the two displays); number 0 -7 are for the UNIT number 54// Number 8 - 15 are for the TENS number ( number 7 and 15 are the DPs of each DIGIT) 55// for displaying the numbers on the Score Board Display and controlling the (WS2812) LEDS the adresses 16 upto 99 are used 56// 24 LEDs are used for backlighting the letters BINGO and 75 for the score board to enable the display of the generated BINGO numbers; 57// all of the LEDs will be controlled with just one wire! from LED_PIN 6 58// as a matter of fact two different types of LED strip are controlled (in parralel)from the same LedPin 6 via two 220 Ohm resistors 59 60#define BRIGHTNESS 250 // sets the brightness of the LEDs to allmost maximum (255) 61 62Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LedPin, NEO_GRB + NEO_KHZ800); 63 64/*2-dimensional array with NUMBER to segment allocations, each NUMBER has its own colum---------------------------------------------------- 65 8 0 66 13 9 5 1 67 14 6 68 12 10 4 2 69 11 15 3 7 70 71 Digit 2 Digit 1 72 Tens Units 73 7 and 15 represent the Decimal Points (DP) 74*/ 75 76// 0 1 2 3 4 5 6 7 8 9 77byte SEGMENTarray [8][10] = { {1,0,1,1,0,1,1,1,1,1,}, //segment 0 or 8 78 {1,1,1,1,1,0,0,1,1,1,}, //segment 1 or 9 79 {1,1,0,1,1,1,1,1,1,1,}, //segment 2 or 10 80 {1,0,1,1,0,1,1,0,1,1,}, //segment 3 or 11 81 {1,0,1,0,0,0,1,0,1,0,}, //segment 4 or 12 82 {1,0,0,0,1,1,1,0,1,1,}, //segment 5 or 13 83 {0,0,1,1,1,1,1,0,1,1,}, //segment 6 or 14 84 {0,0,0,0,0,0,0,0,0,0,}, //segment 7 or 15 85 }; 86 87byte color_scheme[] = { 88 50, 100, 200, 89 100, 150, 250, 90 150, 200, 50, 91 200, 250, 100, 92 250, 50, 150, 93 0, 100, 200, 94 50, 150, 250, 95 100, 200, 0, 96 150, 250, 50, 97 200, 0, 100, 98 250, 50, 200, 99 0, 100, 250, 100 50, 150, 0, 101 250, 0, 0 102}; 103 104/////////////////////////////////////////////////// the setup code that follows, will run once after "Power On" or after a RESET 105void setup() { 106 Serial.begin(9600); 107 pinMode(LedPin, OUTPUT); // initialize the LedPin 6 as an output: 108 pinMode(NewnumberButton, INPUT_PULLUP); // initialize the pushbutton pin 2 as an input: 109 pinMode(BingoButton, INPUT_PULLUP); // initialize the bingobutton pin 4 as an input: 110 111 strip.setBrightness(BRIGHTNESS); 112 strip.begin(); // Initialize all LEDs to "off" 113 strip.show(); 114 115 for (int t = 16; t < 24 ; t++) 116 { 117 strip.setPixelColor(t, 0, 0, 250); // After Power On show the word BINGO on the Score Board with Blue characters 118 strip.show(); // note that the order of colors of the WS2812 LED strip is R,G,B 119 } 120 121 for (count = 0; count < 76 ; count++) { // put all data in the Array SCORE to 0 (Array positions run from 0 to 75; the zero position is not used) 122 SCORE[count] = 0; 123 } 124 125 /*for (int n = 0; n < 10 ; n++) // this code can be used for testing all the numbers from 0 - 9 on the two 7-Segment displays (the 2 DP's are not tested) 126 { 127 for (int s = 0; s < 8 ; s++) 128 { 129 int z = SEGMENTarray [s][n]; 130 int i = 0 + s; int j = 8 + s; 131 strip.setPixelColor(i, z*250, 0, z*50); 132 strip.setPixelColor(j, z*250, 0, z*50); 133 strip.show(); 134 135 Serial.print("["); Serial.print(n); Serial.print("]"); Serial.print("["); Serial.print(s); Serial.print("] = ");Serial.print(z); Serial.print(" "); 136 } 137 delay (1500); 138 Serial.println(); 139 } 140*/ 141 142} 143 144/////////////////////////////////////////////////// the loop code that follows, will run repeatedly until "Power Off" or a RESET 145void loop() { 146 Newnumber = digitalRead(NewnumberButton); 147 148 if (Newnumber == LOW) // no need for a Short delay to eliminate bouncing effects of the button because at first LOW the loop proceeds 149 { 150 randomSeed(millis()); 151 do { 152 GENERATENEWNUMBER (75); // generate a NW_NUMBER between in the range from 1 to 75 153 } // if the NW_NUMBER allready exists: generate again a NW_NUMBER 154 while (NW_NUMBER == SCORE[NW_NUMBER] * NW_NUMBER); 155 156 SCORE[NW_NUMBER] = 1; // put a 1 in the Array at the NW_NUMBER position 157 NUMBER = NW_NUMBER; 158 TENSNUMBER = int (NUMBER / 10); // calculate the decimal value of the NW_NUMBER and the unit value 159 UNITNUMBER = NW_NUMBER - (10 * TENSNUMBER); 160 161 CLEARDISPLAY (); 162 LIGHTSHOW1 (4, 100); // start lightshow1 163 CLEARDISPLAY (); 164 165 //PRINTNUMBERSERIAL(); // print the generated NW_NUMBER to the serial monitor and show the new content of the SCORE array 166 167 DISPLAYNUMBER (TENSNUMBER, UNITNUMBER); 168 169 DISPLAYSCORE (); 170 171 } 172 else { 173 Bingo = digitalRead(BingoButton); 174 if (Bingo == LOW) 175 delay (3000); // a delay of 3 second to eliminate bouncing effects and accidental pushing of the button because 176 if (Bingo == LOW) 177 { 178 BINGOLIGHTSHOW (); 179 for (count = 0; count < 76 ; count++) // put all data in the Array SCORE back to 0 and a new BINGO round can be started 180 { 181 SCORE[count] = 0; 182 } 183 } 184 } 185} 186//////////////////END of LOOP//////////////////////////////////////////////////////////// 187 188 189/////////////////////////////////////////////////// Hereafter follow the specific Functions that are called from within the loop 190void LIGHTSHOW1 (int duration, uint8_t wait) { 191 192for (int t = 16; t < 24 ; t++) 193 { 194 strip.setPixelColor(t, 0, 0, 0); // turn off the BINGO Leds with Blue characters as put upon set up 195 strip.show(); 196 } 197 198 for (int k = 0; k < duration; k++) 199 { // flash the DP leds in a white color 200 strip.setPixelColor(7, 200, 200, 200); 201 strip.show(); 202 delay(wait); 203 strip.setPixelColor(7, 0, 0, 0); 204 strip.setPixelColor(15, 200, 200, 200); 205 strip.show(); 206 delay(wait); 207 strip.setPixelColor(15, 0, 0, 0); 208 } 209 210 int redVal, blueVal, greenVal; 211 for (int k = 1; k < 45 ; k = k + 3) 212 { // run a rainbow color lightshow with colors defined in the Array color_scheme 213 redVal = color_scheme[k]; 214 blueVal = color_scheme[k + 1]; 215 greenVal = color_scheme[k + 2]; 216 217 for (int p = 0; p < 7; p++) 218 { // the collors of the WS2811 strip are adressed in the order R, B, G 219 int i = 0 + p; int j = 8 + p; 220 strip.setPixelColor(i, strip.Color(redVal, blueVal, greenVal) ); 221 strip.setPixelColor(j, strip.Color(greenVal, redVal, blueVal ) ); 222 strip.show(); 223 delay(30); 224 } 225 } 226 227 for (int q = 0; q < 7 ; q++) 228 { // put all segments of the 7-segment displays to "off" 229 int i = 0 + q; int j = 8 + q; 230 strip.setPixelColor(i, 0, 0, 0); 231 strip.setPixelColor(j, 0, 0, 0); 232 strip.show(); 233 } 234} 235 236/////////////////////////////////////////////////Hereafter follows the function for generating the BINGO LIGHTSHOW after the Bingo Button is pushed 237void BINGOLIGHTSHOW () { 238 239for (int l = 0; l<10; l++) 240 { 241 for (int k = 24; k < 39 ; k++) // present a waterfall of white leds on the SCORE board 242 { 243 strip.setPixelColor(k, 200, 200, 200); 244 strip.setPixelColor(k+15, 200, 200, 200); 245 strip.setPixelColor(k+30, 200, 200, 200); 246 strip.setPixelColor(k+45, 200, 200, 200); 247 strip.setPixelColor(k+60, 200, 200, 200); 248 strip.show(); 249 delay(5); 250 strip.setPixelColor(k, 0, 0, 0); 251 strip.setPixelColor(k+15, 0, 0, 0); 252 strip.setPixelColor(k+30, 0, 0, 0); 253 strip.setPixelColor(k+45, 0, 0, 0); 254 strip.setPixelColor(k+60, 0, 0, 0); 255 strip.show(); 256 } 257 258 for (int t = 0; t < 24 ; t++) 259 { 260 strip.setPixelColor(t, 0, 250, 250); // turn on the 7-segment displays and BINGO Leds 261 strip.show(); 262 } 263 delay(50); 264 for (int t = 0; t < 24 ; t++) 265 { 266 strip.setPixelColor(t, 0, 0, 0); // turn off the 7-segment displays and BINGO Leds 267 strip.show(); 268 } 269 } 270} 271 272/////////////////////////////////////////////////// Hereafter follows the function for generating a new number after the New Number Button is pushed 273void GENERATENEWNUMBER (int range) { 274 randNumber = random(1, range + 1); 275 NW_NUMBER = int(randNumber); 276} 277 278/* 279////////////////////////////////////////////////// This function can be used to present the generated NUMBER and show the modified contents of the SCORE array 280void PRINTNUMBERSERIAL () { 281 Serial.print("NUMBER = "); 282 Serial.print(NUMBER); 283 Serial.print(" , TENSNUMBER = "); 284 Serial.print(TENSNUMBER); 285 Serial.print(" , UNITNUMBER = "); 286 Serial.println(UNITNUMBER); 287 count = 1; 288 while (count < 76) 289 { // print all data in the Array SCORE (Array positions from 0 to 75; the zero position remains 0) 290 for (int column = 0; column < 15; column++) 291 { 292 Serial.print("["); Serial.print(count); Serial.print("] = "); Serial.print(SCORE[count]); Serial.print(" "); 293 count++; 294 } 295 Serial.println(""); 296 } 297} 298*/ 299 300///////////////////////////////////////////////// This function is used to display the generated NUMBER on the two 7-Segments displays 301void DISPLAYNUMBER (int TENS, int UNIT) { 302 303 for (int t = 16; t < 24 ; t++) 304 { 305 strip.setPixelColor(t, 200, 0, 0); // turn on the BINGO word Leds in RED characters 306 strip.show(); 307 } 308 309 for (int s = 0; s < 8 ; s++) 310 { // take the data from the SEGMENT array to turn on correct segments for displaying the UNITS and TENS of the NUMBER in RED 311 int t = SEGMENTarray [s][TENS]; 312 int u = SEGMENTarray [s][UNIT]; 313 int i = 0 + s; int j = 8 + s; 314 strip.setPixelColor(i, u*250, 0, 0); 315 if (TENS!=0) { 316 strip.setPixelColor(j, t*250, 0, 0); 317 } 318 else { 319 strip.setPixelColor(j, 0, 0, 0); 320 } 321 strip.show(); 322 } 323} 324 325///////////////////////////////////////////////// This function is used to display the generated NUMBER on the two 7-Segments displays 326void DISPLAYSCORE () { 327 328 for (int t = 16; t < 24 ; t++) 329 { 330 strip.setPixelColor(t, 200, 0, 0); // turn on the BINGO word Leds in RED characters 331 strip.show(); 332 } 333 334 for (int s = 24; s < 100 ; s++) 335 { // turn on the LEDs for the existing Numbers in GREEN 336 int u = SCORE[s-23]; 337 strip.setPixelColor(s, 0, u*200, 0); 338 strip.show(); 339 } 340 strip.setPixelColor((23+NUMBER), 200, 0, 0); // turn on the LEDs for the new Number in RED 341 strip.show(); 342} 343 344///////////////////////////////////////////////// This function is used to clear the two 7-Segments displays 345void CLEARDISPLAY () { 346 347for (int q = 0; q < 7 ; q++) 348 { 349 int i = 0 + q; int j = 8 + q; 350 strip.setPixelColor(i, 0, 0, 0); 351 strip.setPixelColor(j, 0, 0, 0); 352 strip.show(); 353 } 354 355 for (int t = 16; t < 24 ; t++) 356 { 357 strip.setPixelColor(t, 0, 0, 0); // turn off the RED characters of the BINGO word 358 strip.show(); 359 } 360} 361 362
Downloadable files
The BINGO electronics set up
The BINGO electronics set up
The BINGO electronics set up
The BINGO electronics set up
Documentation
drilling template for Score Board
drilling template for Score Board
Lay-out of 7-Segments at A4 size
To be used as a Template for the fronts of the displays
Lay-out of 7-Segments at A4 size
drilling template for Score Board
drilling template for Score Board
Comments
Only logged in users can leave comments