1. Title and introduction (1 pt.)

Our team’s design proposes a solution to regularizing Yale Cohen’s eating schedule. During our first discussion with Yale, we discovered that he has lived with an odd eating schedule for most of his adult life, and currently, he also has a problem with snacking.

Following our learning of Yale’s love of puzzles and etymology, we have created a device that powers on during mealtimes in Yale’s corrected eating schedule. If Yale puts the plate or bowl he ate his meal in on the device’s sensor during this time, it will reward him with a puzzle. Essentially, we are creating a device that uses a reward system to entice Yale to eat at the times he defines as acceptable.

Initial Meeting with Yale: https://courses.ideate.cmu.edu/60-223/s2020/work/initial-meeting-documentation-team-yale/

Prototype Documentation: https://courses.ideate.cmu.edu/60-223/s2020/work/team-yale-prototype-documentation/

2. What we built (5 pts.)

We built a sensor and a puzzle reward. The sensor senses whether a plate is present to check whether Yale has had his meal within the time he is supposed to and that he is adhering with good eating habits. The puzzle reward is a way to incentivize Yale to have better eating habits. When he completes his task of eating at the right time, the puzzle reward would allow Yale to choose from two different puzzles: a sequence puzzle or a hangman puzzle. For the sequence puzzle, Yale will be given three numbers and is supposed to figure out what is the last number in the sequence. For the hangman puzzle, Yale will be given the number of characters in the answer and he would have to figure out what the word is.

Physical Design

Final Design Sketch

Housing and Sensor Plate Front View

Right View

Housing and Sensor Plate Back View

Animated look at the Remote

Rendering of Device in Kitchen

Secondary Front View

Yale wakes up and heads into the kitchen. The puzzle box lights up letting him know its time to eat. He eats a bowl of cereal and places the bowl on the plate sensor. He proceeds to play a game of hangman.

Puzzle Reward

The video shows the game play of the sequence game:

The following video shows the gameplay for the hangman game:

 

Ultrasonic Sensor

The video shows how the circuit works: The ultrasonic sensor first senses the distance of the plates to the sensor. If the distance is less than 20cm, and the waiting time of the object is equal 10 secs, the reward for the day is displayed to Yale.

3. How we got here (5 pts.)

Puzzle Reward

Decision 1: the puzzles we wanted to include

During our initial meeting with Yale, one thing that stood out to us is how he really enjoys puzzles. We discussed the different puzzles that he liked and figured that he is both interested in words and in math. He is also very adventurous in terms of exploring new biking trails and open to any sort of puzzles.

When we were creating our initial prototypes, we had to decide which puzzle we wanted to prototype since there was a limited amount of time. Also, we want to be able to flesh out one puzzle well rather than have a bunch of half baked puzzle prototypes which would not give us good feedback from users who we are user testing on. At this point, the puzzles we were considering are:

  1. Math puzzle
    • For this puzzle, we wanted to give Yale a math problem to solve since he has a strong mathematical background. However, we soon realise due to the lack of real estate on the LCD screen, it was very hard to effectively show a long math problem (such as the bridge crossing problem). Even though we are aware that there is a possibility of having the screen scroll to show more text, we think it would not be a wise decision to have too many moving digital components for someone like Yale. We then thought that having equations and sequences would be the few options that would fit into the limitation of screen width
  2. Hangman
    • For this puzzle, Yale will be given a word and would have to guess what the word is. Just like hangman, he would have seven lives to guess the word. The reason we thought he might like this is mainly because he mentioned that he enjoys etymology, the study of the origin of words and the way in which their meanings have changed throughout history.
  3. Mechanical puzzle
    • As we started brainstorming the different puzzles that Yale enjoys, we realise that a lot of these puzzles are just a google search away for him. This is why we wanted to think of something out of the box that is more physical. We came up with the idea of a mechanical puzzle where we will be using switches, potentiometers and tilt sensors. In order to win the game, Yale would have to place the components in the right configuration. Each time he submits his answers, instead of knowing which component is right, he will only be told how many components are correct
  4. Fun facts
    • Instead of having all the rewards requiring Yale to spend time solving a problem, we wanted to provide an option where Yale is able to be rewarded without having to spend a lot of time with the system. For this option, we wanted to just display a fun fact.
  5. Trivia questions
    • A middle ground between a puzzle that would take around five minutes and a fun fact thrown to Yale is questions that would take a minute or two to answer. This allows for some sort of thinking and interaction but yet would not take Yale a long time to answer. We thought of using some true or false questions or creating a series of multiple choice questions and have it be his reward.

In the end, we decided to prototype the mechanical puzzle, because it was something that we were not sure whether Yale would enjoy. After prototyping an engineering prototype and a physical prototype, we managed to talk to Yale to get his opinions. It was very vague as to whether he wanted a mechanical puzzle because he would say that it would be “interesting” because it is “something he has never seen”. This led us to a decision point whether to include the mechanical puzzle. The decision would affect the design of the device because it would require more components which might make the design more complicated.

We decided to take his vague opinions to be indicators that he was not very interested in exploring a mechanical puzzle and thus decided to work with things he was very specific about that he liked – words and math. We then pivot our rewards to include a sequence puzzle and the hangman game.

brainstorming LCD flow

Decision: components to use

After our decision to use the sequence puzzle and the hangman game as our reward, we had to look into what are the components that we want to use. The main goals of this decision are:

  1. Make sure that we are able to reuse as many components across the two puzzles
  2. Make sure that the components are very clear to the user
  3. Make sure the flow of events is intuitive

Taking into consideration our goals, we came up with a series of options for the components we can use:

  • Option 1: 1 or 4 knobs, one button → use encoder and pushbutton
    • One knob to go through numbers (0-9)
    • Three knobs to go through alphabets? (A-Z) Each knob will control around 8 alphabets
    • Button to move to the next space? And to submit
  • Option 2: 2 buttons
    • One button to move to the next space and submit
    • One button to circle through options (A → Z → A)
  • Option 3: 3 buttons
    • One button to move to the next space and submit
    • One button to go to the next option (A → B)
    • One button to go to the previous option (B → A)

In an ideal world where we would have access to multiple parts and are not constrained by Tinkercad components, it would be best for us to use a rotary encoder, and modify the first option that we have.

 

Therefore, for our components, we decided to use:

  1. One knob to loop through numbers, from 0 to 9
  2. One knob to loop through alphabets, from A to Z
  3. One button to confirm the selection
  4. One button to move to the next option, such as moving to next place in a digit or moving from the sequence puzzle option to the hangman puzzle option
  5. One button to move to the previous option

components used

Sensor

Firstly, the ultrasonic sensor circuit was built with the physical Arduino components. Feed backs from the prototype helped to identify modifications like adding a small time delay (say 10 seconds) before showing the game. Another modification was to improvise the LCD display from 16×4 size that we  initially planned to use, to 16×2 available on tinkercad.

Physical coupling of the circuit

Schematic

Sketch

Iteraction and Appearance

Early design sketch with first iteration of remote

Early design sketch with Bluetooth Communication between Sensor plate and device.

 

The method of interaction with the design was the first problem that I had to tackle. The first ideas I had involved placing our components on the facade of the device; however, I quickly abandoned that idea because placing the buttons and knobs on the device would limit the flexibility with which Yale could interact with the device. Additionally, I was worried that being so close to the device would make it uncomfortable to use and read the LCD. My next idea was to create a remote control device. My first iteration was inspired by the design for the Nintendo GameCube controller. The reason that I used this video game controller as a point of reference is that video game controllers are generally designed ergonomically to encourage comfortable play. However, following discussions with Yale, I abandoned this iteration because he prefered to use a single-handed device. The final design came after looking at and studying some of the television remotes in my house, which were rectilinear and encouraged single-handed use.

The appearance of the device was an easier problem to solve than interaction; however, there were many iterations before the final design. The main purpose of the housing of the device initially was to host the LCD screen and the components. The purpose of the sensor plate was to sense whether or not Yale had eaten and activate the puzzles. The sensor plate accomplishes this by detecting whether or not Yale has placed a bowl or plate on it during the time in which the device is activated. As such, early on I made the decision to make it round and flat to visually complement the objects it detects. However, the housing unit changed dramatically. The first iteration was a simple box, and while it was functional and would work, it was too generic to be truly beneficial. I then tried a more organic, rounded shape to create a visual contrast between the device and the other devices in the kitchen;  however, the white on white aesthetic of the device drew the eye as it is, and the rounded shape might prove difficult to interact with. Once I abandoned the idea of placing the interactive components of the device on the housing, I was free to downsize the device and I experimented with a trapezoidal shape that allowed for the LCD screen to be read easier. This is the design for the housing I ultimately went with. At this time, I also made the decision to separate the housing from the sensor plate and connect them with a wire to encourage flexibility.

4. Conclusions and lessons learned (5 pts.)

Response to Feedback

The rendering looked great. That said, consider using a device that is internet-enabled, such as a Particle Photon, so that you can pull new puzzles down to keep the novelty from wearing off.

This is something that we really wanted to do but was unable to due to the limitations we faced when working with tinkercad. In order to combat that problem, we tried to use as much randomness as we can so that the sequence is not very predictable. Also, this would mean that we would not have to hardcode a bunch of sequences, which would take a lot of memory on the arduino. By being able to get puzzles online, we will also not be limiting the sequence puzzles to be merely based on a function. One interesting puzzle we can have is the sequence 3, 3, 5, 4, 4, _. This sequence shows the number of letters is the word one, two, three, four, five and so on, which means the answer would be 3. Being able to obtain interesting puzzles like these would be awesome, but we also have to account for the explanation for the answer of the puzzles, which would improve the usability of the puzzle.

The design is very simple and pleasing. It seems like the project will need you to program lots and lots of puzzles so it doesn’t get boring, so that might be difficult

It is true that we would need a wide variety of puzzles so that it would not get boring. I would say that the sequence puzzle might be easy to crack once Yale figures out what the equation is. Ways we have tried to make it more challenging is by limiting it to three lives and also having a time limit. Other ideas we have to make the sequence more challenging would be to have less of the sequence given, which may or may not be solvable. In terms of the hangman game, one way to make it more interesting is to incorporate different languages that still uses the alphabets.

I like how personal this intervention is to Yale’s lifestyle. It’s interesting that solving puzzles serves as a reward. I wonder whether the current input buttons are sustainable over time, as they can become cumbersome to engage with if you were to dial through every letter and number. 

It would be interesting to be able to integrate with an actual keyboard which would make typing a word so much easier. However, one thing we wanted to do is to keep the design minimal. Also, we wanted to make sure it will be a feasible project to work on using tinkercad. It would be nice to be able to possibly connect to Yale’s phone or laptop, which would make the system simple but given our expertise, this is not something feasible for us.

I love that  there are two parts connected by IR receivers and transmitters. Does that currently work in the code or is that limited by tinkercad?

Unfortunately, we were not able to have the IR receivers and transmitters working on tinkercad. We would like to get it working if we are able to work on it further because it would greatly improve the usability of the system and not have a bunch of wires running around.

The design is really nice. Are the times for the eating schedule set? I think it would be convenient if it was adjustable.

Currently, the times are not scheduled due to the restrictions we have on tinkercad. In a perfect world, we would be using the real time clock component to figure out the time of the day. It would be nice to also start customising when meal times are.

Having an endless supply of puzzles will keep it interesting and motivating.  Really like idea of connecting to the internet for more puzzle choices. The device helps with regulating meal time but does it help with the snacking problem?

Unfortunately, the snacking problem cannot be enforced but we hope that by regulating meal times, Yale would have less need to have to snack at off hours.

Working With an Older Person

Working with an older person was a unique and valuable learning experience. Something that surprised me about Yale in particular was his vast knowledge of code and some of our components due to his work in software development before he retired. This knowledge allowed him to be more involved in some of the more technical aspects of the project than I originally expected. Working with an older person with a lot of life experience was both helpful and challenging in the context of this project in particular. The Puzzle Box is an assistive device that is attempting to modify the habits of our client Yale. Designing a device that can successfully modify somebody’s habits over time is a challenging problem to tackle to begin with; however, this challenge becomes much harder when one is trying to change habits that have been set for years or even decades. However, the long life that an older person has lived means that they are very familiar and sure of their interests, their likes, and their dislikes. This came especially helpful in our design of the reward system. Yale has established his love of puzzles for many years, and while he was open to a variety of puzzles and was willing to try new things, he also knew exactly what kind of puzzles he likes and that have kept his interest for so long.  Next time we work on designing an assistive device for an older individual, we should still take advantage of their knowledge of their interests in order to design a pleasing and appropriate device.

Working Remotely

Working remotely has been unexpectedly better than we had thought. Possibly because of the amazing team and a lively client that we had. Although, we cannot for sure say it was 100 percent because it had its challenges but one major advantage we had working remotely was that it was an opportunity to think outside the box and to put into practice what we learnt in the first half of the semester. Times when we had to improvise and make some necessary adjustments. 

Some major challenges we had were scheduling meeting times to reach the client, internet connectivity issues, easy understanding of client’s needs and limited resources/parts to work with. Due to the different calendar, we had to reschedule some meeting times with the client. Also, there was a time we had difficulty understanding what the client actually wanted which we thought could have been easier if we had a real physical conversation. Also, there was a time we had internet issues while talking to the client, and that also hindered the conversation. 

Another major challenge was limitation of parts and resources. Probably because the course as a whole is project based, working remotely did not help much with that. As good as tinkercad was, it had some limitations, for example, some components we could have used if we had physical access to the lab, were not present in the tinkercad. Also, one challenge we had was a storage problem. The original idea was to have different combinations of words as puzzles for Yale, but we realized that there would be a larger memory need for that word permutations. Yale suggested a cloud service option, but that would be out of scope for the objectives of this project.  

What worked better than we expected was the cooperation among the team and designation of the work. It was unexpectedly better because despite the distance and present situation of things, each team member delivered what was expected to make things work. We could also reach out to one another for help and suggestions. 

What we might have done differently in retrospect to allow remote collaboration work more successfully would be to have a team progress report or update. With that, it would be easy to track each team member’s progress. 

5. Technical details (4 pts.)

Ultrasonic Sensor code to detect plate.

// Ultrasonic sensor code to detect plates
// This code detects the presence of the plate. Usually there is a time lag of about 10secs before the game 
// is displayed to Yale (Client). 

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

/*
   Create an LCD display object called "screen" with I2C address 0x27
   which is 16 columns wide and 2 rows tall.
*/

LiquidCrystal_I2C lcd(0x27, 16, 2);

// defining the Trig and Echo pins.
const int triggerPin = 8;
const int echoPin = 9;
const int buzzer = 10;
long duration = 0;
int distance = 0;

unsigned long previous_timer = 0;
unsigned long previous_timer_bf = 0;
unsigned long interval = 10;
unsigned long breakfastTime = 20; //assuming he eats his breakfast at 20secs (o'clock) everyday
unsigned long game_display_interval = 10;
unsigned long previous_timer_reset = 0;

// function to read the distance
long readUltrasonicDistance(int triggerPin, int echoPin)
{
  pinMode(triggerPin, OUTPUT);  // Clear the trigger
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);
  // Sets the trigger pin to HIGH state for 10 microseconds
  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(triggerPin, LOW);
  pinMode(echoPin, INPUT);
  // Reads the echo pin, and returns the sound wave travel time in microseconds
  return pulseIn(echoPin, HIGH);
}


void setup() {
  // initializing the lcd:
  lcd.init();
  lcd.backlight();
  Serial.begin(9600);

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  pinMode(buzzer, OUTPUT);
}

void loop() {

  previous_timer = millis() / 1000;
  
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Hello Yale");
  

  // measure the ping time in distance
  distance = 0.01723 * readUltrasonicDistance(2, 3);

  if (millis() / 1000 == breakfastTime) {
    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print((String)"Time 4 Breakfast");
    tone(buzzer, 1000); // Send 1KHz sound signal...
    noTone(buzzer);     // Stop sound...
    while (millis() / 1000 < previous_timer + interval) {
      //wait approx. [period] ms
    }
  }

  if (distance <= 20 && (millis() / 1000) - previous_timer_bf >= game_display_interval) {
    lcd.clear();
    lcd.setCursor(0, 1);
    lcd.print((String)"Game 4 today is:");
    while (millis() / 1000 < previous_timer + interval) {
      //wait approx. [period] ms
    }
    previous_timer_bf = millis() / 1000;
  }

}

sensor schematics

Puzzle Reward System code

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  
const int NUM_ROT = A0;
const int ALP_ROT = A1;

const int LEFT_BUT = 6;
const int RIGHT_BUT = 7;
const int CONFIRM_BUT = 8;
const int SUBMIT_BUT = 9;

// SUBMIT BUTTON THINGS

int buttonState;
int lastButtonState = LOW;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 20;

// RIGHT BUTTON THINGS

int rightButtonState;
int rightLastButtonState = LOW;
unsigned long rightLastDebounceTime = 0;
unsigned long rightDebounceDelay = 20;

// HANGMAN THINGS

String alphabets[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
String words[] = {"HELLO", "THERE", "SOMETHING", "SOMETHING", "NOTHING", "LOVELY", "POOPY", "NICE", "GIRL", "GIRLFRIEND"};
const int NUM_WORDS = 10;
String answer;
String guess;
String curr;

// GENERAL THINGS

int seqLife = 3;
int hangmanLife = 7;
bool gameOver = false;
bool gameWon = false;
String gameMode;
String gameModeChoices[] = {"HANGMAN", "SEQUENCE"};
int gameModeChoice = 0;
bool gameModeChosen;

unsigned long gameTime;
const int timeLimitSecs = 300;

byte heart[8] = {
  B00000,
  B00000,
  B01010,
  B11111,
  B11111,
  B01110,
  B00100,
  B00000
};

byte clockFace[] = {
  B00000,
  B01110,
  B10101,
  B10101,
  B10111,
  B10001,
  B01110,
  B00000
};


// SEQUENCE THINGS

int seqAnswer[4] = {1, 2, 3, 4};
int seqCurr;
int seqGuess = 0;
int seqCursor = 0;

void setup() {
  lcd.createChar(0, heart);
  lcd.createChar(1, clockFace);
  lcd.begin(16, 2);
  
  pinMode(LEFT_BUT, INPUT_PULLUP);
  pinMode(RIGHT_BUT, INPUT_PULLUP);
  pinMode(CONFIRM_BUT, INPUT_PULLUP);
  pinMode(SUBMIT_BUT, INPUT_PULLUP);

  pinMode(NUM_ROT, INPUT);
  pinMode(ALP_ROT, INPUT);

  Serial.begin(9600);
  
  createHangmanAnswer();
  createSequenceAnswer();
}

void createHangmanAnswer() {
  answer = words[random(0, NUM_WORDS)];
  for (int i=0; i < answer.length(); i++) {
    guess += "_";
  }
  Serial.println(answer);
}

void createSequenceAnswer() {
  int operation1 = random(4);
  int operation2 = random(4);
  int number1 = random(1, 10);
  int number2 = random(1, 10);

  if (operation1 == 0) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = seqAnswer[i] + number1;
    }
  } else if (operation1 == 1) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = pow(seqAnswer[i], number1);
    }
  } else if (operation1 == 2) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = seqAnswer[i] * number1;
    }
  } else if (operation1 == 3) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = seqAnswer[i] - number1;
    }
  }

  if (operation2 == 0) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = abs(seqAnswer[i] + number2);
    }
  } else if (operation2 == 1) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = abs(seqAnswer[i] - number2);
    }
  } else if (operation2 == 2) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = abs(seqAnswer[i] * number2);
    }
  } else if (operation2 == 3) {
    for (int i=0; i < 4; i ++) {
      seqAnswer[i] = abs(pow(seqAnswer[i], number2));
    }
  }

  Serial.println((String) operation1 + " " + operation2 + " " + number1 + " " + number2);
  Serial.println((String) "sequence!: " + seqAnswer[0] + " " + seqAnswer[1] + " " + seqAnswer[2] + " " + seqAnswer[3] + " ");
}

void loop() {
//  Serial.println((String) "Your word is: " + answer);

  if (gameModeChosen) {
    int alpReading = analogRead(ALP_ROT);
    int numReading = analogRead(NUM_ROT);
  
    if (gameOver) {
      gameOverDisplay();
    } else {
      if (gameMode == "HANGMAN") {
        playHangman(alpReading);
      } else if (gameMode == "SEQUENCE") {
        playSequence(numReading);
      }
    }
  } else {
    chooseGameMode();
  }
}

/* GENERAL THINGS */

void gameOverDisplay() {
  lcd.clear();
    lcd.setCursor(0,0);
  if (!gameWon) {
    lcd.print("GAME OVER, YALE");
  } else {
    lcd.print("CONGRATS, YALE!");
  }
}

void chooseGameMode() {
  lcd.setCursor(2,0);
  lcd.print("Hangman");
  lcd.setCursor(2, 1);
  lcd.print("Sequence");

  modeRightButtonPressed();
    
  lcd.setCursor(0,gameModeChoice);
  lcd.print("-");

  modeConfirmButtonPressed();
}

void modeRightButtonPressed() {
  int reading = digitalRead(RIGHT_BUT);
  if (reading != rightLastButtonState) {
    rightLastDebounceTime = millis();
  }

  if ((millis() - rightLastDebounceTime) > rightDebounceDelay) {
    if (reading != rightButtonState) {
      rightButtonState = reading;
      if (rightButtonState == LOW) {
        lcd.clear();
        gameTime = millis();
        if (gameModeChoice == 0) {
          gameModeChoice = 1;
        } else {
          gameModeChoice = 0;
        }
      }
    }
  }
  rightLastButtonState = reading;
}

void modeConfirmButtonPressed() {
  int reading = digitalRead(CONFIRM_BUT);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == LOW) {
        gameMode = gameModeChoices[gameModeChoice];
        gameModeChosen = true;
        lcd.clear();
      }
    }
  }
  lastButtonState = reading;
}

/* SEQUENCE GAME THINGS */

void playSequence(int numReading) {
  
  seqCurr = numReading/103;
  lcd.noBlink();
  lcd.setCursor(0, 1);
  lcd.print(seqGuess);

  lcd.setCursor(seqCursor, 1);
  lcd.print(seqCurr);
  // Serial.println((String)"current!: " + seqCurr);

  lcd.setCursor(0, 0);
  lcd.print((String) seqAnswer[0] + "," + seqAnswer[1] + "," + seqAnswer[2] + ", __");
  

  sequenceCheckRightButtonPressed();
  sequenceCheckConfirmButtonPressed();

  lcd.setCursor(12, 0);
  lcd.write(byte(0));
  lcd.setCursor(14, 0);
  lcd.print(seqLife);

  lcd.setCursor(12, 1);
  lcd.write(byte(1));
  lcd.setCursor(13, 1);
  lcd.print(timeLimitSecs-(millis() - gameTime)/1000);
}

void sequenceCheckRightButtonPressed() {
  int reading = digitalRead(RIGHT_BUT);
  if (reading != rightLastButtonState) {
    rightLastDebounceTime = millis();
  }

  if ((millis() - rightLastDebounceTime) > rightDebounceDelay) {
    if (reading != rightButtonState) {
      rightButtonState = reading;
      if (rightButtonState == LOW) {
        Serial.println((String) "NEXT NEXT " + curr);
        seqGuess = seqCurr * 10;
        seqCursor += 1;
        Serial.println("seqGuess: " + String(seqGuess));
      }
    }
  }
  rightLastButtonState = reading;
}

void sequenceCheckConfirmButtonPressed() {
  int reading = digitalRead(CONFIRM_BUT);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == LOW) {
        Serial.println((String) "curr is: " + seqCurr);
        Serial.println((String) "guess is: " + seqGuess);
        seqGuess += seqCurr;
        Serial.println((String) "new guess is: " + seqGuess);

        sequenceSubmitGuess();
      }
    }
  }
  lastButtonState = reading;
}

void sequenceSubmitGuess() {
  if (seqAnswer[3] == seqGuess) {
    Serial.println("RIGHT ANSWER");
    gameOver = true;
    gameWon = true;
  } else {
    Serial.println("WRONG ANSWER");
    lcd.clear();
    seqLife -= 1;
    seqGuess = 0;
    seqCursor = 0;
    if (seqLife == 0) {
      gameOver = true;
    }
  }
}

/* HANGMAN THINGS */

void playHangman(int alpReading) {
  curr = alphabets[alpReading/40];
  hangmanCheckButtonPressed();
  hangmanLcdDisplay();
  delay(10); 
}

void hangmanCheckButtonPressed() {
  int reading = digitalRead(CONFIRM_BUT);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == LOW) {
        Serial.println((String) "curr is: " + curr);
        hangmanSubmitGuess();
      }
    }
  }
  lastButtonState = reading;
}

void hangmanSubmitGuess() {
  if (answer.indexOf(curr) != -1) {
    Serial.println("you got it!");
    Serial.println((String) "curr is: " + curr);
    guess = showCharInString(guess, answer, curr);
    Serial.println((String) "new guess is: " + guess);

    if (guess.indexOf("_") == -1) {
      gameOver = true;
      gameWon = true;
    }
  } else {
    Serial.println("does not exist");
    hangmanLife -= 1;
    if (hangmanLife == 0) {
      gameOver = true;
    }
  }
}

String showCharInString(String guess, String string, String chr) {
  String result = "";
  for (int i = 0; i < string.length(); i ++) {
    if (String(string[i])  == chr || String(guess[i]) != "_") {
      result += string[i];
    } else {
      result += "_";
    }
  }
  return result;
}

void hangmanLcdDisplay() {
  if (!gameOver) {
    lcd.setCursor(0, 0);
    lcd.print(guess);
    lcd.setCursor(0, 1);
    lcd.print(curr);

    lcd.setCursor(12, 0);
    lcd.write(byte(0));
    lcd.setCursor(14, 0);
    lcd.print(hangmanLife);

    lcd.setCursor(12, 1);
    lcd.write(byte(1));
    lcd.setCursor(13, 1);
    lcd.print(timeLimitSecs-(millis() - gameTime)/1000);
  }
}

 

Schematics

puzzle reward schematics