Build Sheets

01 · Brief

The screen the wiring game unlocked tells the players to review a communication document and route a distress signal through a chain of relay stations. The stations are marked on a star chart in their game materials, and the route is a series of directions from one station to the next.

Four buttons on the console, up, left, right, and down, take the route one press at a time. The Nano checks the sequence as it comes in and reports over USB serial to the Pi.

When the sequence lands, the Pi changes the screen to an incoming message. That message carries the launch command code for the final game.

02 · System

PI USB 5 V→ NANO
PI 4NANOBUTTONS ×4

03 · Source

Escape_Game_Final_Directional.ino

void loop(){
  
  submitButton.update();
  if (submitButton.fell()){
    digitalWrite(buttonLed, HIGH);
    delay(500);
    digitalWrite(buttonLed, LOW);
    currentStep = 0;
  };

  for(int i=0; i<4; i++){    
    // Update the state of this switch
    buttons[i].update();
    // ...has it just been pressed?
    if(buttons[i].fell()){
    
      if(i == correctSequence[currentStep]){
        
        inputCorrect = true;
        Serial.println("true");
        currentStep++;
        Serial.println(currentStep);

      } else {
        // Set flag that user has made at least one incorrect entry in the sequence
        inputCorrect = false;
        Serial.println("false");
        Serial.println(currentStep);
        currentStep = 0;
        }
  
      if(currentStep == numSteps){
        
        if (inputCorrect == true && messageSent == false){
        digitalWrite(buttonLed, HIGH);
        On_Solve();
        Serial.println("buttonpush");
        Serial.println("solved");
        delay(500);
        Serial.println("solved");
        messageSent = true;
           
        }     
      }     
    }
  }
}
Lines 39–85 of 92 · Full source →

04 · Lessons

This game was a digital version of a directional lock. I got some good practice working with arrays.

This is another idea I took from the Playful Technology youtube channel, parts of the code were written by Alastair Aitchison while other parts were written by me.