Build Sheets

Source

Escape_Game_Final_Connectwires.ino

//for the device that does LEDs and RFID
#include <SPI.h>
#include <MFRC522.h>
#include <FastLED.h>

#define RST_PIN 9           // Configurable, see typical pin layout above
#define SS_PIN 10          // Configurable, see typical pin layout above SDA
#define NUM_LEDS 64
#define LED_PIN 6

const int patternL = 8;
CRGB leds[NUM_LEDS];

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
byte block;
byte len;
MFRC522::StatusCode status;

String UIDA = "19 EB E3 AF"; //H 25.x
String UIDB = "40 F8 E3 AF"; //G 16y
String UIDC = "22 09 AF 9F"; //F 88v
String UIDD = "81 CF AE 9F"; //X 29.1c
String UIDE = "42 AA E4 AF"; //Z 8.7L

uint8_t patternA[patternL] = {56, 55, 40, 38, 26, 20, 12, 3};
uint32_t colorsA[patternL] = {0x000000FF, 0x000000FF, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00};
uint8_t patternB[patternL] = {57, 54, 41, 38, 24, 23, 8, 7};
uint32_t colorsB[patternL] = {0x00FFFF00, 0x00FFFF00, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF0000, 0x00FF8000, 0x00FF8000};
uint8_t patternC[patternL] = {58, 53, 42, 36, 27, 19, 11, 4};
uint32_t colorsC[patternL] = {0x00FF8000, 0x00FF8000, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x0000CC00, 0x0000CC00};
uint8_t patternD[patternL] = {59, 52, 43, 36, 26, 21, 10, 5};
uint32_t colorsD[patternL] = {0x0000CC00, 0x0000CC00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x00FFFF00, 0x000000FF, 0x000000FF};
uint8_t patternE[patternL] = {60, 51, 44, 36, 26, 22, 9, 6};
uint32_t colorsE[patternL] = {0x00FF0000, 0x00FF0000, 0x0000CC00, 0x0000CC00, 0x0000CC00, 0x0000CC00, 0x00FF0000, 0x00FF0000};



void showPatternA(){
  FastLED.clearData();
  for (int i = 0; i < patternL; i++){
  leds[ patternA[i] ] = colorsA[i];
  FastLED.show();
  delay(100);
  Serial.println("worked");
  }
  delay(1000);
  FastLED.clear(true);
}


void showPatternB(){
  FastLED.clearData();
  for (int i = 0; i < patternL; i++){
  leds[ patternB[i] ] = colorsB[i];
  FastLED.show();
  delay(100);
  }
  delay(1000);
  FastLED.clear(true);
}

void showPatternC(){
  FastLED.clearData();
  for (int i = 0; i < patternL; i++){
  leds[ patternC[i] ] = colorsC[i];
  FastLED.show();
  delay(100);
  }
  delay(1000);
  FastLED.clear(true);
}

void showPatternD(){
  FastLED.clearData();
  for (int i = 0; i < patternL; i++){
  leds[ patternD[i] ] = colorsD[i];
  FastLED.show();
  delay(100);
  }
  delay(1000);
  FastLED.clear(true);
}

void showPatternE(){
  FastLED.clearData();
  for (int i = 0; i < patternL; i++){
  leds[ patternE[i] ] = colorsE[i];
  FastLED.show();
  delay(100);
  Serial.print("worked");
  }
  delay(1000);
  FastLED.clear(true);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);  
  Serial.println("start");                                         // Initialize serial communications with the PC
  SPI.begin();                                                  // Init SPI bus
  mfrc522.PCD_Init();    
  FastLED.addLeds<WS2812B, LED_PIN, GRB> (leds, NUM_LEDS);
  FastLED.setBrightness(50);
  //FastLED.clearData();
  //leds[15] = CRGB::Red;
  FastLED.clear(true);
}

void loop() {
  // put your main code here, to run repeatedly:
  MFRC522::MIFARE_Key key;
  for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;

  // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }
  //Show UID on serial monitor
  String ID = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    ID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(mfrc522.uid.uidByte[i], HEX));
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    delay(300);
  }
  ID.toUpperCase();
    if (ID.substring(1) == UIDA) {
      showPatternA();
    } else if (ID.substring(1) == UIDB){
      showPatternB();
    } else if (ID.substring(1) == UIDC){
      showPatternC();
    } else if (ID.substring(1) == UIDD){
      showPatternD();
    } else if (ID.substring(1) == UIDE){
      showPatternE();
    }

}