Modified Crystal Ball: help for set up and coding

Hi! I'm a beginner at arduino.

For a personal project I'm modifying the Crystal Ball project for Monopoly Chance and Community Chest cards. There are two buttons: 'Chance' and 'Community Chest'. When you push the chance button, you'll get Chance answers and so on. I'm wondering how to set it up on the breadboard, and how to do the coding for the buttons. So far I haven't found any instructable similar to this.

All help is much appreciated. :slight_smile: Thanks!

This is the code: (The responses here are for Community Chest cards)

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


const int switchPin = 6;


int switchState = 0;


int prevSwitchState = 0;


int reply;

void setup() {
  
  lcd.begin(16, 2);

  // set up the switch pin as an input
  pinMode(switchPin, INPUT);

  // Print a message to the LCD.
  lcd.print("Select one:");
  lcd.setCursor(0, 1);
  // print to the second line
  lcd.print("Crystal Ball!");
}

void loop() {
  // check the status of the switch
  switchState = digitalRead(switchPin);

  // compare the switchState to its previous state
  if (switchState != prevSwitchState) {
    // if the state has changed from HIGH to LOW
    // you know that the ball has been tilted from
    // one direction to the other
    if (switchState == LOW) {
      // randomly chose a reply
      reply = random(14);
      // clean up the screen before printing a new reply
      lcd.clear();
  
      // choose a saying to print baed on the value in reply
      switch (reply) {
        case 0:
            // set the cursor to column 0, line 0
          lcd.setCursor(0, 0);
            // print some text
          lcd.print("Advance to GO -");
            // move the cursor to the second line
          lcd.setCursor(0, 1);
          lcd.print("Collect $200");
          break;

        case 1:
          lcd.setCursor(0, 0);
          lcd.print("Bank error -");
          lcd.setCursor(0, 1);
          lcd.print("Collect $75");
          break;

        case 2:
          lcd.setCursor(0, 0);
          lcd.print("Doctor's fees -");
          lcd.setCursor(0, 1);
          lcd.print("Pay $50");
          break;

        case 3:
          lcd.setCursor(0, 0);
          lcd.print("Get out of jail");
          lcd.setCursor(0, 1);
          lcd.print("free");
          break;

        case 4:
          lcd.setCursor(0, 0);
          lcd.print("Go to jail, do");
            lcd.setCursor(0, 1);
          lcd.print("not pass GO");
          break;

        case 5:
           lcd.setCursor(0, 0);
          lcd.print("It's your Bday!");
          lcd.setCursor(0, 1);
          lcd.print("collect $10/pax");
          break;

        case 6:
          lcd.setCursor(0, 0);
          lcd.print("Opera Night -");
          lcd.setCursor(0, 1);
          lcd.print("collect $50/pax");
          break;

        case 7:
          lcd.setCursor(0, 0);
          lcd.print("Income Tax");
          lcd.setCursor(0, 1);
          lcd.print("refunds you $20");
          break;
         
         
         case 8:
          lcd.setCursor(0, 0);
          lcd.print("Insurance grows");
          lcd.setCursor(0, 1);
          lcd.print("collect $20");
          break;


          case 9:
          lcd.setCursor(0, 0);
          lcd.print("Pay Hospital");
          lcd.setCursor(0, 1);
          lcd.print("fees of $100");
          break;

           case 10:
          lcd.setCursor(0, 0);
          lcd.print("Pay school");
          lcd.setCursor(0, 1);
          lcd.print("fees of $50");
          break;

           case 11:
          lcd.setCursor(0, 0);
          lcd.print("Consultancy fee");
          lcd.setCursor(0, 1);
          lcd.print("receive $25");
          break;

           case 12:
          lcd.setCursor(0, 0);
          lcd.print("You inherit $100");
          lcd.setCursor(0, 1);
          lcd.print("(you lucky guy!)");
          break;

        
           case 13:
            lcd.setCursor(0, 0);
          lcd.print("Sale from stock");
            lcd.setCursor(0, 1);
          lcd.print("earns you $50!");
          break;
      }
    }
  }
  // save the current switch state as the last state
  prevSwitchState = switchState;
}

AULU:
So far I haven't found any instructable similar to this.

That's a good thing.

if (switchState == LOW) {

OK, so this means it's looking for a LOW (zero volts) value on the pin to tell it that the button has been pushed. That means the pin should be pulled up to HIGH with a resistor when the switch isn't pressed. Normally this can be done with the built-in pullup resistor inside the Arduino but this particular sketch doesn't do that. I would change the line in setup() to use INPUT_PULLUP:

  // set up the switch pin as an input with internal pullup
  pinMode(switchPin, INPUT_PULLUP);

Then wire up a switch or button between that pin and ground. Try it out! Let us know if it works.

lcd.print("Collect $200");

Do yourself a huge favour and save precious RAM.
Everywhere you've got a line that looks a bit like the one above, modify it so it likes more like this lcd.print(F("Collect $200"));