Arduino Slot Machine.

by simaopintocorreia in Circuits > Arduino

1393 Views, 3 Favorites, 0 Comments

Arduino Slot Machine.

SUNP0107.JPG

You like gambling ?And you don't want to spent a cent? If the answer is yes then this project is for you...

Supplies

  1. Arduino
  2. 16*2 LCD display
  3. push button
  4. piezo speaker
  5. 10kR resistor
  6. some jumper wires
  7. breadboard
  8. USB ca

The Schematic.

slot.png

Wire the components like the scheme.

Arduino Code:

/*#######################################################################################################################
## Created by; simaopintocorreia. Date; 16 / Aug / '19 ## ## ## License ;CreativeCommons Atributtion-NonComercial-NoDerives (CC-BY-AT-NC-ND) ## ## ## ######################################################################################################################## */

#include <LiquidCrystal.h>

int lucky1; int lucky2; int lucky3;

byte cardinal [8] = { 0b01010, 0b01010, 0b11111, 0b01010, 0b01010, 0b11111, 0b01010, 0b01010 }; byte love [8] = { 0b00000, 0b01010, 0b11111, 0b11111, 0b01110, 0b01110, 0b00100, 0b00000 }; byte clube[8] = { 0b01110, 0b10101, 0b11111, 0b10101, 0b01110, 0b00100, 0b01000, 0b10000 }; byte omega [8] = { 0b00000, 0b01110, 0b10001, 0b10001, 0b10001, 0b01010, 0b11011, 0b00000 }; byte dollar [8] = { 0b00100, 0b01111, 0b10100, 0b01110, 0b00101, 0b00101, 0b11110, 0b00100 }; #define PB 9 LiquidCrystal lcd(2,3,4,5,6,7); void setup() { // put your setup code here, to run once:

//setup the bytes: lcd.createChar(1,cardinal); lcd.createChar(2,love); lcd.createChar(3,clube); lcd.createChar(4,omega); lcd.createChar(5,dollar);

//setup the pins: pinMode (PB,INPUT); pinMode (11,OUTPUT);

//initialize the lcd: lcd.begin(16,2); for (int i=31;i<700;i++){ tone(11,i); delay(10); } for (int i=700;i>31;i--){ tone(11,i); delay(10); } noTone(11); randomSeed(A0); }

void loop() { // put your main code here, to run repeatedly: repeat1: lcd.clear(); lcd.print("Press to Spin!!"); lcd.noDisplay(); delay(750); lcd.display(); delay(750); if (digitalRead(PB)==HIGH){ tone(11,400); delay(100); noTone(11), tone(11,300); delay(100); tone(11,500); delay(100); noTone(11); lucky1 = random(1,6); lucky2 = random(1,6); lucky3 = random(1,6); // lucky1 =3; // lucky2 =3; // lucky3 =3; lcd.clear(); lcd.print("Good Luck!"); delay(2000); lcd.clear(); lcd.print("Spinning"); lcd.leftToRight(); lcd.write('.'); delay(750); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,400); delay(750); noTone(11); delay(100); lcd.write('.'); tone(11,550); delay(750); noTone(11); delay(100); lcd.clear(); lcd.setCursor(4,0); lcd.write(byte(lucky1)); lcd.setCursor(8,0); lcd.write(byte(lucky2)); lcd.setCursor(12,0); lcd.write(byte(lucky3)); delay(5000); if((lucky1 == lucky2)&&(lucky2 == lucky3)){ lcd.clear(); lcd.print("YOU WIN!!"); tone(11,400); delay(100); noTone(11), tone(11,300); delay(100); tone(11,500); delay(300); noTone(11); delay(10000); goto repeat1; }else{ lcd.clear(); lcd.print("Sorry,YOU LOSE"); tone(11,400); delay(100); noTone(11), tone(11,300); delay(100); tone(11,100); delay(100); noTone(11); delay(5000); tone(11,400); delay(100); noTone(11), tone(11,300); delay(100); tone(11,500); delay(100); noTone(11); goto repeat1; } } delay(200); }

Downloads