Components and supplies
Arduino Due
LED (generic)
Pachinko Arrange Ball Machine
Relay Shield for Particle Photon I²C 8-Channel SPDT 10-Amp
Resistor 221 ohm
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
Pachinko Arrange Ball "Hustler" Game Control Board
arduino
I would call this a Working work in progress, I know this code could be drastically reduced, but my lack of better understanding of the code made me write this line by line. Additionally there are some variables in the declaration that aren't used in this code, but in another version I'm working on. This game is sometimes called a pinball, but it's more like a slot machine. This is a unique variant of a pachinko called an "arrange ball". You insert a coin and the games release 16 balls into a shooter trough. Using the plunger it shoots a ball around an arc and the balls fall through a series of pins, targets, goals and ultimately into 16 numbered slots or 2 return slots. There is a light matrix in the center and if you get the right arrangement of numbers at the end of the game the machine pays out that number of coins. It basically just a series of switches and LEDs that correspond to each other. The numbered LEDs basically just light up when the ball lands in a slot and rests on a leaf switch. I had this trigger a value of 1 for each switch because the switches are old and I was getting some flickering when I did a straight digitalRead and digitalWrite, that and I needed some variable to use for scoring. After you go through all 16 balls you have to press what I'm calling a payout switch. It triggers a game over Led(s) to light and goes through the scoring and pays accordingly. A new coin through a coin mechanism triggers a switch and starts a new game, resetting all the lights and variables. Additionally there is a "low coin" switch on a tube that makes sure there is enough coins to cover at least a maximum payout of 15 coins. If not, a low coin light flashes and coin rejection solenoid engages so a new game cannot be started until the coin storage is back to an acceptable level. I would love some pointers or suggestions on ways to improve this. there are a few delay()'s in here but none of them seem to have any ill effect on game play.
1//Declarations 2//Lights 3const int led1 = 1; 4const int led2 = 2; 5const int led3 = 3; 6const int led4 = 4; 7const int led5 = 5; 8const int led6 = 6; 9const int led7 = 7; 10const int led8 = 8; 11const int led9 = 9; 12const int led10 = 10; 13const int led11 = 11; 14const int led12 = 12; 15const int led13 = 13; 16const int led14 = 14; 17const int led15 = 15; 18const int led16 = 16; 19const int greenLed = 17; 20const int redLed = 18; 21const int doubleLed = 19; 22const int ballChuteLed1 = 20; 23const int ballChuteLed2 = 21; 24const int gameOverLed1 = 22; 25const int lowCoinLed2 = 23; 26const int gameOverLed2 = 24; 27const int lowCoinLed3 = 25; 28const int gameOverLed3 = 26; 29const int lowCoinLed1 = 27; 30//Solenoids 31const int payoutSolenoid = 28; 32const int coinRejectSolenoid = 29; 33const int ballSolenoid = 30; 34// Switchs 35const int sw1 = 31; 36const int sw2 = 32; 37const int sw3 = 33; 38const int sw4 = 34; 39const int sw5 = 35; 40const int sw6 = 36; 41const int sw7 = 37; 42const int sw8 = 38; 43const int sw9 = 39; 44const int sw10 = 40; 45const int sw11 = 41; 46const int sw12 = 42; 47const int sw13 = 43; 48const int sw14 = 44; 49const int sw15 = 45; 50const int sw16 = 46; 51const int swGreen = 47; 52const int swRed = 48; 53const int swFull = 49; 54const int swDouble = 50; 55const int swCoin = 51; 56const int swPay = 52; 57const int swLow = 53; 58 59int ss1 = 0; 60int ps1 = 0; 61int sc1 = 0; 62int ss2 = 0; 63int ps2 = 0; 64int sc2 = 0; 65int ss3 = 0; 66int ps3 = 0; 67int sc3 = 0; 68int ss4 = 0; 69int ps4 = 0; 70int sc4 = 0; 71int ss5 = 0; 72int ps5 = 0; 73int sc5 = 0; 74int ss6 = 0; 75int ps6 = 0; 76int sc6 = 0; 77int ss7 = 0; 78int ps7 = 0; 79int sc7 = 0; 80int ss8 = 0; 81int ps8 = 0; 82int sc8 = 0; 83int ss9 = 0; 84int ps9 = 0; 85int sc9 = 0; 86int ss10 = 0; 87int ps10 = 0; 88int sc10 = 0; 89int ss11 = 0; 90int ps11 = 0; 91int sc11 = 0; 92int ss12 = 0; 93int ps12 = 0; 94int sc12 = 0; 95int ss13 = 0; 96int ps13 = 0; 97int sc13 = 0; 98int ss14 = 0; 99int ps14 = 0; 100int sc14 = 0; 101int ss15 = 0; 102int ps15 = 0; 103int sc15 = 0; 104int ss16 = 0; 105int ps16 = 0; 106int sc16 = 0; 107int ssGreen = 0; 108int psGreen = 0; 109int scGreen = 0; 110int ssRed = 0; 111int psRed = 0; 112int scRed = 0; 113int ssFull = 0; 114int psFull = 0; 115int scFull = 0; 116int ssDouble = 0; 117int psDouble = 0; 118int scDouble = 0; 119int ssCoin = 0; 120int psCoin = 0; 121int scCoin = 0; 122int ssPay = 0; 123int psPay = 0; 124int scPay = 0; 125int runOnce = 0; 126 127 128// LED Blink without delay 129int ledState = LOW; // ledState used to set the LED 130int ledState2 = LOW; 131// Generally, you should use "unsigned long" for variables that hold time 132// The value will quickly become too large for an int to store 133unsigned long previousMillis = 0; // will store last time LED was updated 134 135// constants won't change: 136const long interval = 1000; // interval at which to blink (milliseconds) 137const long interval2 = 300; 138 139int newGame = 0; 140void setup() { 141 // put your setup code here, to run once: 142 143 //OUPUT LIGHTS 144 pinMode(led1, OUTPUT); 145 pinMode(led2, OUTPUT); 146 pinMode(led3, OUTPUT); 147 pinMode(led4, OUTPUT); 148 pinMode(led5, OUTPUT); 149 pinMode(led6, OUTPUT); 150 pinMode(led7, OUTPUT); 151 pinMode(led8, OUTPUT); 152 pinMode(led9, OUTPUT); 153 pinMode(led10, OUTPUT); 154 pinMode(led11, OUTPUT); 155 pinMode(led12, OUTPUT); 156 pinMode(led13, OUTPUT); 157 pinMode(led14, OUTPUT); 158 pinMode(led15, OUTPUT); 159 pinMode(led16, OUTPUT); 160 pinMode(greenLed, OUTPUT); 161 pinMode(redLed, OUTPUT); 162 pinMode(doubleLed, OUTPUT); 163 pinMode(lowCoinLed1, OUTPUT); 164 pinMode(gameOverLed1, OUTPUT); 165 pinMode(lowCoinLed1, OUTPUT); 166 pinMode(gameOverLed2, OUTPUT); 167 pinMode(lowCoinLed3, OUTPUT); 168 pinMode(gameOverLed3, OUTPUT); 169 pinMode(ballChuteLed1, OUTPUT); 170 pinMode(ballChuteLed2, OUTPUT); 171 172 // OUPUT RELAYS 173 pinMode(payoutSolenoid, OUTPUT); 174 pinMode(ballSolenoid, OUTPUT); 175 pinMode(coinRejectSolenoid, OUTPUT); 176 177 digitalWrite(ballSolenoid, HIGH); 178 digitalWrite(coinRejectSolenoid, HIGH); 179 digitalWrite(payoutSolenoid, HIGH); 180 181 //INPUT SWITCHES 182 pinMode(sw1, INPUT_PULLUP); 183 pinMode(sw2, INPUT_PULLUP); 184 pinMode(sw3, INPUT_PULLUP); 185 pinMode(sw4, INPUT_PULLUP); 186 pinMode(sw5, INPUT_PULLUP); 187 pinMode(sw6, INPUT_PULLUP); 188 pinMode(sw7, INPUT_PULLUP); 189 pinMode(sw8, INPUT_PULLUP); 190 pinMode(sw9, INPUT_PULLUP); 191 pinMode(sw10, INPUT_PULLUP); 192 pinMode(sw11, INPUT_PULLUP); 193 pinMode(sw12, INPUT_PULLUP); 194 pinMode(sw13, INPUT_PULLUP); 195 pinMode(sw14, INPUT_PULLUP); 196 pinMode(sw15, INPUT_PULLUP); 197 pinMode(sw16, INPUT_PULLUP); 198 pinMode(swGreen, INPUT_PULLUP); 199 pinMode(swRed, INPUT_PULLUP); 200 pinMode(swDouble, INPUT_PULLUP); 201 pinMode(swFull, INPUT_PULLUP); 202 pinMode(swCoin, INPUT_PULLUP); 203 pinMode(swPay, INPUT_PULLUP); 204 pinMode(swLow, INPUT_PULLUP); 205 206 // Lamp Test on initial power 207 delay(251); 208 digitalWrite(led1, HIGH); 209 delay(251); 210 digitalWrite(led1, LOW); 211 delay(251); 212 digitalWrite(led2, HIGH); 213 delay(251); 214 digitalWrite(led2, LOW); 215 delay(251); 216 digitalWrite(led3, HIGH); 217 delay(251); 218 digitalWrite(led3, LOW); 219 delay(251); 220 digitalWrite(led4, HIGH); 221 delay(251); 222 digitalWrite(led4, LOW); 223 delay(251); 224 digitalWrite(led5, HIGH); 225 delay(251); 226 digitalWrite(led5, LOW); 227 delay(251); 228 digitalWrite(led6, HIGH); 229 delay(251); 230 digitalWrite(led6, LOW); 231 delay(251); 232 digitalWrite(led7, HIGH); 233 delay(251); 234 digitalWrite(led7, LOW); 235 delay(251); 236 digitalWrite(led8, HIGH); 237 delay(251); 238 digitalWrite(led8, LOW); 239 delay(251); 240 digitalWrite(led9, HIGH); 241 delay(251); 242 digitalWrite(led9, LOW); 243 delay(251); 244 digitalWrite(led10, HIGH); 245 delay(251); 246 digitalWrite(led10, LOW); 247 delay(251); 248 digitalWrite(led11, HIGH); 249 delay(251); 250 digitalWrite(led11, LOW); 251 delay(251); 252 digitalWrite(led12, HIGH); 253 delay(251); 254 digitalWrite(led12, LOW); 255 delay(251); 256 digitalWrite(led13, HIGH); 257 delay(251); 258 digitalWrite(led13, LOW); 259 delay(251); 260 digitalWrite(led14, HIGH); 261 delay(251); 262 digitalWrite(led14, LOW); 263 delay(251); 264 digitalWrite(led15, HIGH); 265 delay(251); 266 digitalWrite(led15, LOW); 267 delay(251); 268 digitalWrite(led16, HIGH); 269 delay(251); 270 digitalWrite(led16, LOW); 271 delay(251); 272 digitalWrite(greenLed, HIGH); 273 delay(251); 274 digitalWrite(greenLed, LOW); 275 delay(251); 276 digitalWrite(redLed, HIGH); 277 delay(251); 278 digitalWrite(redLed, LOW); 279 delay(251); 280 digitalWrite(doubleLed, HIGH); 281 delay(251); 282 digitalWrite(doubleLed, LOW); 283 delay(251); 284 digitalWrite(lowCoinLed1, HIGH); 285 delay(251); 286 digitalWrite(lowCoinLed1, LOW); 287 delay(251); 288 digitalWrite(lowCoinLed2, HIGH); 289 delay(251); 290 digitalWrite(lowCoinLed2, LOW); 291 delay(251); 292 digitalWrite(lowCoinLed3, HIGH); 293 delay(251); 294 digitalWrite(lowCoinLed3, LOW); 295 delay(251); 296 digitalWrite(gameOverLed1, HIGH); 297 delay(251); 298 digitalWrite(gameOverLed1, LOW); 299 delay(251); 300 digitalWrite(gameOverLed2, HIGH); 301 delay(251); 302 digitalWrite(gameOverLed2, LOW); 303 delay(251); 304 digitalWrite(gameOverLed3, HIGH); 305 delay(251); 306 digitalWrite(gameOverLed3, LOW); 307 delay(251); 308 digitalWrite(ballChuteLed1, HIGH); 309 delay(251); 310 digitalWrite(ballChuteLed1, LOW); 311 delay(251); 312 digitalWrite(gameOverLed1, HIGH); 313 digitalWrite(lowCoinLed1, HIGH); 314 digitalWrite(gameOverLed2, HIGH); 315 digitalWrite(lowCoinLed2, HIGH); 316 digitalWrite(gameOverLed3, HIGH); 317 digitalWrite(lowCoinLed3, HIGH); 318 delay(351); 319 digitalWrite(gameOverLed1, LOW); 320 digitalWrite(lowCoinLed1, LOW); 321 digitalWrite(gameOverLed2, LOW); 322 digitalWrite(lowCoinLed2, LOW); 323 digitalWrite(gameOverLed3, LOW); 324 digitalWrite(lowCoinLed3, LOW); 325 digitalWrite(greenLed, HIGH); 326 digitalWrite(led6, HIGH); 327 digitalWrite(led2, HIGH); 328 digitalWrite(led14, HIGH); 329 delay(351); 330 digitalWrite(greenLed, LOW); 331 digitalWrite(led6, LOW); 332 digitalWrite(led2, LOW); 333 digitalWrite(led14, LOW); 334 digitalWrite(led11, HIGH); 335 digitalWrite(led1, HIGH); 336 digitalWrite(led15, HIGH); 337 digitalWrite(led5, HIGH); 338 delay(351); 339 digitalWrite(led11, LOW); 340 digitalWrite(led1, LOW); 341 digitalWrite(led15, LOW); 342 digitalWrite(led5, LOW); 343 digitalWrite(doubleLed, HIGH); 344 digitalWrite(led13, HIGH); 345 digitalWrite(led7, HIGH); 346 digitalWrite(led3, HIGH); 347 digitalWrite(led9, HIGH); 348 delay(351); 349 digitalWrite(doubleLed, LOW); 350 digitalWrite(led13, LOW); 351 digitalWrite(led7, LOW); 352 digitalWrite(led3, LOW); 353 digitalWrite(led9, LOW); 354 digitalWrite(led10, HIGH); 355 digitalWrite(led4, HIGH); 356 digitalWrite(led12, HIGH); 357 digitalWrite(led8, HIGH); 358 digitalWrite(led16, HIGH); 359 digitalWrite(redLed, HIGH); 360 delay(351); 361 digitalWrite(led10, LOW); 362 digitalWrite(led4, LOW); 363 digitalWrite(led12, LOW); 364 digitalWrite(led8, LOW); 365 digitalWrite(led16, LOW); 366 digitalWrite(redLed, LOW); 367 digitalWrite(ballChuteLed1, HIGH); 368 digitalWrite(ballChuteLed2, HIGH); 369 delay(351); 370 digitalWrite(ballChuteLed1, LOW); 371 digitalWrite(ballChuteLed2, LOW); 372 // End Lamp Test 373 // Solenoid Test 374 digitalWrite(coinRejectSolenoid, LOW); 375 delay(500); 376 digitalWrite(coinRejectSolenoid, HIGH); 377 delay(500); 378 digitalWrite(payoutSolenoid, LOW); 379 delay(500); 380 digitalWrite(payoutSolenoid, HIGH); 381 delay(500); 382 /* uncomment to also test ball release 383 digitalWrite(ballReleaseSolenoid, LOW); 384 delay(700); 385 */ 386 digitalWrite(ballSolenoid, HIGH); 387 // END Solenoid Test 388} // END setup 389 390void loop() { 391 // put your main code here, to run repeatedly: 392 digitalWrite(ballSolenoid, HIGH); 393 digitalWrite(payoutSolenoid, HIGH); 394 395 // LED Blinkers (global) 396 unsigned long currentMillis = millis(); 397 398 // Check Low Coin Switch 399 if (digitalRead(swLow) == HIGH) { 400 digitalWrite(lowCoinLed1, LOW); 401 digitalWrite(lowCoinLed2, LOW); 402 digitalWrite(lowCoinLed3, LOW); 403 digitalWrite(coinRejectSolenoid, HIGH); 404 } 405 if (digitalRead(swLow) == LOW) { 406 if (currentMillis - previousMillis >= interval) { 407 previousMillis = currentMillis; 408 if (ledState == LOW) { 409 ledState = HIGH; 410 } else { 411 ledState = LOW; 412 } 413 digitalWrite(lowCoinLed1, ledState); 414 digitalWrite(lowCoinLed2, ledState); 415 digitalWrite(lowCoinLed3, ledState); 416 digitalWrite(coinRejectSolenoid, LOW); 417 } 418 } 419 420 421 422 // COUNTERS 423 // Check Payout Switch 424 ssPay = digitalRead(swPay); 425 if (ssPay != psPay) { 426 if (ssPay == LOW) { 427 scPay = 1; 428 } 429 delay(50); 430 } 431 psPay = ssPay; 432 433 // Check Coin Slot Switch 434 ssCoin = digitalRead(swCoin); 435 if (ssCoin != psCoin) { 436 if (ssCoin == LOW) { 437 scCoin = 1; 438 } 439 delay(50); 440 } 441 psCoin = ssCoin; 442 443 // If New Game Check Switches and Light LEDs 444 if (scCoin == 1) { 445 digitalWrite(ballSolenoid, LOW); 446 delay(500); 447 digitalWrite(ballSolenoid, HIGH); 448 digitalWrite(led1, LOW); 449 digitalWrite(led2, LOW); 450 digitalWrite(led3, LOW); 451 digitalWrite(led4, LOW); 452 digitalWrite(led5, LOW); 453 digitalWrite(led6, LOW); 454 digitalWrite(led7, LOW); 455 digitalWrite(led8, LOW); 456 digitalWrite(led9, LOW); 457 digitalWrite(led10, LOW); 458 digitalWrite(led11, LOW); 459 digitalWrite(led12, LOW); 460 digitalWrite(led13, LOW); 461 digitalWrite(led14, LOW); 462 digitalWrite(led15, LOW); 463 digitalWrite(led16, LOW); 464 digitalWrite(greenLed, LOW); 465 digitalWrite(redLed, LOW); 466 digitalWrite(doubleLed, LOW); 467 newGame = 1; 468 } 469 scCoin = 0; 470 if (newGame == 1) { 471 digitalWrite(gameOverLed1, LOW); 472 digitalWrite(gameOverLed2, LOW); 473 digitalWrite(gameOverLed3, LOW); 474 digitalWrite(ballChuteLed1, HIGH); 475 digitalWrite(ballChuteLed2, HIGH); 476 477 // Check Full Chance Zone Switch 478 ssFull = digitalRead(swFull); 479 if (ssFull != psFull) { 480 if (ssFull == LOW) { 481 scFull = 1; 482 } 483 delay(50); 484 } 485 psFull = ssFull; 486 487 // Check Green Zone Switch 488 ssGreen = digitalRead(swGreen); 489 if (ssGreen != psGreen) { 490 if (ssGreen == LOW) { 491 scGreen = 1; 492 } 493 delay(50); 494 } 495 psGreen = ssGreen; 496 if (scGreen == 1 || scFull == 1) { 497 if (currentMillis - previousMillis >= interval) { 498 previousMillis = currentMillis; 499 if (ledState == LOW) { 500 ledState = HIGH; 501 } else { 502 ledState = LOW; 503 } 504 } 505 digitalWrite(greenLed, ledState); 506 } 507 508 // Check Red Zone Switch 509 ssRed = digitalRead(swRed); 510 if (ssRed != psRed) { 511 if (ssRed == LOW) { 512 scRed = 1; 513 } 514 delay(50); 515 } 516 psRed = ssRed; 517 if (scRed == 1 || scFull == 1) { 518 if (currentMillis - previousMillis >= interval) { 519 previousMillis = currentMillis; 520 if (ledState == LOW) { 521 ledState = HIGH; 522 } else { 523 ledState = LOW; 524 } 525 } 526 digitalWrite(redLed, ledState); 527 } 528 529 // Check Double Up Switch 530 ssDouble = digitalRead(swDouble); 531 if (ssDouble != psDouble) { 532 if (ssDouble == LOW) { 533 scDouble = 1; 534 } 535 delay(50); 536 } 537 psDouble = ssDouble; 538 if (scDouble == 1 || scFull == 1) { 539 if (currentMillis - previousMillis >= interval) { 540 previousMillis = currentMillis; 541 if (ledState == LOW) { 542 ledState = HIGH; 543 } else { 544 ledState = LOW; 545 } 546 } 547 digitalWrite(doubleLed, ledState); 548 } 549 550 // Check Number Slot Switch 1 551 if (digitalRead(sw1) == LOW) { 552 ss1 = 1; 553 } 554 if (ss1 == 1) { 555 digitalWrite(led1, HIGH); 556 } else { 557 digitalWrite(led1, LOW); 558 } 559 560 // Check Number Slot Switch 2 561 if (digitalRead(sw2) == LOW) { 562 ss2 = 1; 563 } 564 if (ss2 == 1) { 565 digitalWrite(led2, HIGH); 566 } else { 567 digitalWrite(led2, LOW); 568 } 569 570 // Check Number Slot Switch 3 571 if (digitalRead(sw3) == LOW) { 572 ss3 = 1; 573 } 574 if (ss3 == 1) { 575 digitalWrite(led3, HIGH); 576 } else { 577 digitalWrite(led3, LOW); 578 } 579 580 // Check Number Slot Switch 4 581 if (digitalRead(sw4) == LOW) { 582 ss4 = 1; 583 } 584 if (ss4 == 1) { 585 digitalWrite(led4, HIGH); 586 } else { 587 digitalWrite(led4, LOW); 588 } 589 590 // Check Number Slot Switch 5 591 if (digitalRead(sw5) == LOW) { 592 ss5 = 1; 593 } 594 if (ss5 == 1) { 595 digitalWrite(led5, HIGH); 596 } else { 597 digitalWrite(led5, LOW); 598 } 599 600 // Check Number Slot Switch 6 601 if (digitalRead(sw6) == LOW) { 602 ss6 = 1; 603 } 604 if (ss6 == 1) { 605 digitalWrite(led6, HIGH); 606 } else { 607 digitalWrite(led6, LOW); 608 } 609 610 // Check Number Slot Switch 7 611 if (digitalRead(sw7) == LOW) { 612 ss7 = 1; 613 } 614 if (ss7 == 1) { 615 digitalWrite(led7, HIGH); 616 } else { 617 digitalWrite(led7, LOW); 618 } 619 620 // Check Number Slot Switch 8 621 if (digitalRead(sw8) == LOW) { 622 ss8 = 1; 623 } 624 if (ss8 == 1) { 625 digitalWrite(led8, HIGH); 626 } else { 627 digitalWrite(led8, LOW); 628 } 629 630 // Check Number Slot Switch 9 631 if (digitalRead(sw9) == LOW) { 632 ss9 = 1; 633 } 634 if (ss9 == 1) { 635 digitalWrite(led9, HIGH); 636 } else { 637 digitalWrite(led9, LOW); 638 } 639 640 // Check Number Slot Switch 10 641 if (digitalRead(sw10) == LOW) { 642 ss10 = 1; 643 } 644 if (ss10 == 1) { 645 digitalWrite(led10, HIGH); 646 } else { 647 digitalWrite(led10, LOW); 648 } 649 650 // Check Number Slot Switch 11 651 if (digitalRead(sw11) == LOW) { 652 ss11 = 1; 653 } 654 if (ss11 == 1) { 655 digitalWrite(led11, HIGH); 656 } else { 657 digitalWrite(led11, LOW); 658 } 659 660 // Check Number Slot Switch 12 661 if (digitalRead(sw12) == LOW) { 662 ss12 = 1; 663 } 664 if (ss12 == 1) { 665 digitalWrite(led12, HIGH); 666 } else { 667 digitalWrite(led12, LOW); 668 } 669 670 // Check Number Slot Switch 13 671 if (digitalRead(sw13) == LOW) { 672 ss13 = 1; 673 } 674 if (ss13 == 1) { 675 digitalWrite(led13, HIGH); 676 } else { 677 digitalWrite(led13, LOW); 678 } 679 680 // Check Number Slot Switch 14 681 if (digitalRead(sw14) == LOW) { 682 ss14 = 1; 683 } 684 if (ss14 == 1) { 685 digitalWrite(led14, HIGH); 686 } else { 687 digitalWrite(led14, LOW); 688 } 689 690 // Check Number Slot Switch 15 691 if (digitalRead(sw15) == LOW) { 692 sc15 = 1; 693 } 694 if (ss15 == 1) { 695 digitalWrite(led15, HIGH); 696 } else { 697 digitalWrite(led15, LOW); 698 } 699 700 // Check Number Slot Switch 16 701 if (digitalRead(sw16) == LOW) { 702 sc16 = 1; 703 } 704 if (ss16 == 1) { 705 digitalWrite(led16, HIGH); 706 } else { 707 digitalWrite(led16, LOW); 708 } 709 710 } //END newGame = 1 711 712 if (newGame == 0) { 713 //Reset Everything 714 ss1 = 0; 715 ps1 = 0; 716 sc1 = 0; 717 ss2 = 0; 718 ps2 = 0; 719 sc2 = 0; 720 ss3 = 0; 721 ps3 = 0; 722 sc3 = 0; 723 ss4 = 0; 724 ps4 = 0; 725 sc4 = 0; 726 ss5 = 0; 727 ps5 = 0; 728 sc5 = 0; 729 ss6 = 0; 730 ps6 = 0; 731 sc6 = 0; 732 ss7 = 0; 733 ps7 = 0; 734 sc7 = 0; 735 ss8 = 0; 736 ps8 = 0; 737 sc8 = 0; 738 ss9 = 0; 739 ps9 = 0; 740 sc9 = 0; 741 ss10 = 0; 742 ps10 = 0; 743 sc10 = 0; 744 ss11 = 0; 745 ps11 = 0; 746 sc11 = 0; 747 ss12 = 0; 748 ps12 = 0; 749 sc12 = 0; 750 ss13 = 0; 751 ps13 = 0; 752 sc13 = 0; 753 ss14 = 0; 754 ps14 = 0; 755 sc15 = 0; 756 ss16 = 0; 757 ps16 = 0; 758 sc16 = 0; 759 ssGreen = 0; 760 psGreen = 0; 761 scGreen = 0; 762 ssRed = 0; 763 psRed = 0; 764 scRed = 0; 765 ssFull = 0; 766 psFull = 0; 767 scFull = 0; 768 ssDouble = 0; 769 psDouble = 0; 770 scDouble = 0; 771 } //END newGame = 0 772 773 // Payout 774 if (scPay == 1) { 775 if (newGame == 1) { 776 // Scoring 777 // Line 1 scoreboard matrix 2,6 & 14 pays 1 778 if (ss2 == 1 && ss6 == 1 && ss14 == 1) { 779 digitalWrite(payoutSolenoid, LOW); 780 delay(500); 781 digitalWrite(payoutSolenoid, HIGH); 782 delay(500); 783 } 784 785 // Line 2 scoreboard matrix 1,5,11 & 15 pays 1 786 if (ss1 == 1 && ss5 == 1 && ss11 == 1 && ss15 == 1) { 787 digitalWrite(payoutSolenoid, LOW); 788 delay(500); 789 digitalWrite(payoutSolenoid, HIGH); 790 delay(500); 791 } 792 793 // Line 3 scoreboard matrix 3,7,9 & 13 pays 2 with double up lit pays double 794 if (ss3 == 1 && ss7 == 1 && ss9 == 1 && ss13 == 1) { 795 digitalWrite(payoutSolenoid, LOW); 796 delay(500); 797 digitalWrite(payoutSolenoid, HIGH); 798 delay(500); 799 digitalWrite(payoutSolenoid, LOW); 800 delay(500); 801 digitalWrite(payoutSolenoid, HIGH); 802 delay(500); 803 if (scDouble >= 1) { 804 digitalWrite(payoutSolenoid, LOW); 805 delay(500); 806 digitalWrite(payoutSolenoid, HIGH); 807 delay(500); 808 digitalWrite(payoutSolenoid, LOW); 809 delay(500); 810 digitalWrite(payoutSolenoid, HIGH); 811 delay(500); 812 } 813 } 814 815 // Line 4 scoreboard matrix 4,6,8,10 & 12 pays 3 with double up lit pays double 816 if (ss4 == 1 && ss16 == 1 && ss8 == 1 && ss10 == 1 && ss12 == 1) { 817 digitalWrite(payoutSolenoid, LOW); 818 delay(500); 819 digitalWrite(payoutSolenoid, HIGH); 820 delay(500); 821 digitalWrite(payoutSolenoid, LOW); 822 delay(500); 823 digitalWrite(payoutSolenoid, HIGH); 824 delay(500); 825 digitalWrite(payoutSolenoid, LOW); 826 delay(500); 827 digitalWrite(payoutSolenoid, HIGH); 828 delay(500); 829 if (scDouble >= 1) { 830 digitalWrite(payoutSolenoid, LOW); 831 delay(500); 832 digitalWrite(payoutSolenoid, HIGH); 833 delay(500); 834 digitalWrite(payoutSolenoid, LOW); 835 delay(500); 836 digitalWrite(payoutSolenoid, HIGH); 837 delay(500); 838 digitalWrite(payoutSolenoid, LOW); 839 delay(500); 840 digitalWrite(payoutSolenoid, HIGH); 841 delay(500); 842 } 843 } 844 845 // green and red zone skill shot scoring 846 if (ss1 == 1 && ss6 == 1 && ss11 == 1 && ss15 == 1 && ssGreen == 1) { 847 digitalWrite(payoutSolenoid, LOW); 848 delay(500); 849 digitalWrite(payoutSolenoid, HIGH); 850 delay(500); 851 } 852 if (ss3 == 1 && ss8 == 1 && ss9 == 1 && ss16 == 1 && ssRed == 1) { 853 digitalWrite(payoutSolenoid, LOW); 854 delay(500); 855 digitalWrite(payoutSolenoid, HIGH); 856 delay(500); 857 digitalWrite(payoutSolenoid, LOW); 858 delay(500); 859 digitalWrite(payoutSolenoid, HIGH); 860 delay(500); 861 } 862 newGame = 0; 863 } 864 } //END scPay 865 866 scPay = 0; 867 868 if (scPay == 0 && scCoin == 0 && newGame == 0) { 869 if (currentMillis - previousMillis >= interval) { 870 previousMillis = currentMillis; 871 if (ledState == LOW) { 872 ledState = HIGH; 873 } else { 874 ledState = LOW; 875 } 876 } 877 digitalWrite(gameOverLed1, ledState); 878 digitalWrite(gameOverLed2, ledState); 879 digitalWrite(gameOverLed3, ledState); 880 } 881 882 883 884 885 886 887} // END LOOP
Downloadable files
Pachinko Arrange Ball "Hustler"
Replacing a DOA circuit board in what I believe is a 35+ year old PAchinko Machine. Updated all lamps to LED, added a couple LED's to the ball chute so now you can see how many balls you have left to play. Built a lamp and relay/solenoid test into the initial power-up(setup). All switch use inter pull up (INPUT_PULLUP) using original machine simple leaf switches
Pachinko Arrange Ball "Hustler"
Pachinko Arrange Ball "Hustler"
Replacing a DOA circuit board in what I believe is a 35+ year old PAchinko Machine. Updated all lamps to LED, added a couple LED's to the ball chute so now you can see how many balls you have left to play. Built a lamp and relay/solenoid test into the initial power-up(setup). All switch use inter pull up (INPUT_PULLUP) using original machine simple leaf switches
Pachinko Arrange Ball "Hustler"
Comments
Only logged in users can leave comments