05 May 2026

Jasmine Darman Final

 This was a project with a large end goal and scope that wasn't able to be achieved in time. However, the progress made was still significant. This was the large schematic and is what I based the small design on: 


The current prototype can run a base LED script, RFID reader script, and locate button pushes with an array. 

The base neo LED script is from neo pixels known as Simple. 

The other scripting: 

//First check what the current saved UID is- depending on what it is will affect how things work
//next check where a button press is located
// if it is, check if it's being held down or if it's just a quick tap
// held down means it's saving the object location to a new location
// quick tap means it's checking for where this object can go in relation to others- light things up

//to check with the array:
//send power high through one of the yellow parts
//check if this power is given into one of the blue things



#include <MFRC522.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN        0 // On Trinket or Gemma, suggest changing this to 1

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 16 // Popular NeoPixel ring size
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels

//Info for Character tags
//A = Wall, red can not go

#define RST_PIN 9  
#define SS_PIN 6

MFRC522 reader(SS_PIN, RST_PIN);


//parts of the array yellow:

int yellowArray[] = {1, 2, 3};
int yellowArrayLength = 3;


//parts of the array blue:
int blueArray[] = {A0, A1, A2};
int blueArrayLength = 3;

//array that stores the location ...? bqasically which one went off for electricity and what was the result back
int hexArray[9];
int hexArrayLength = 9;

//Saved RFID type here
char tokenType;
int tokenLocation;




void setup() {
    // set all yellow pins to output - sending electricity out  
  for(int i = 0; i < yellowArrayLength; i ++ ){
    pinMode(yellowArray[i], OUTPUT);
  }
  //set all the blue pins to input- taking electricity in to read
    for(int i = 0; i < blueArrayLength; i ++ ){
    pinMode(blueArray[i], INPUT);
  }
  Serial.begin(9600);  // Initialize serial communications with the PC


//RFID Reader
  while (!Serial)
    ;                  
  SPI.begin();        
  reader.PCD_Init();  


//pixels
  #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
    clock_prescale_set(clock_div_1);
  #endif
    // END of Trinket-specific code.

    pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)

    Serial.println("Ready"); // test - confirm serial is working
}

void loop() {
 // char pieceLetter = ReadCard(); //always check if something is being saved in the rfid character - just using characters for this - this will get the ID type
  pixels.clear();
   pixels.show();
   
   
 CheckButtons();
HandleRFID();
   
 //LightLeds(tokenType, tokenLocation);
 //pixels.show();





 

}

void HandleRFID(){
  if (!reader.PICC_IsNewCardPresent()) {
    return;
  }

  // Select one of the cards
  if (!reader.PICC_ReadCardSerial()) {
    return;
  }



  if (reader.PICC_GetType(reader.uid.sak) == MFRC522::PICC_TYPE_MIFARE_UL) {
 
    tokenType = ReadCard();
    Serial.println("read card");
  } else {
    Serial.println(F("Unsupported card type for NTAG215 write."));
  }

  // End communication with this card before waiting for the next one.
  reader.PICC_HaltA();
  reader.PCD_StopCrypto1();
  delay(300); // delay should not be here if handling buttons - maybe aync it
 
}

void LightLeds(char pieceType, int pieceLocation){

//location not 0
if(pieceLocation != 0){
//character
  if(pieceType == 'A'){
   
    //peiceLocation is a wall   for(int i=0; i<NUMPIXELS; i++) {
    pixels.setPixelColor(pieceLocation -1 , pixels.Color(255, 0, 0));

    pixels.show();  
    delay(DELAYVAL);

   

  }


 
}
 

}
char ReadCard(){
  const byte page = 4; // MIFARE_Read returns 4 pages (16 bytes) starting here
  byte data[18];
  byte size = sizeof(data);
  MFRC522::StatusCode status = reader.MIFARE_Read(page, data, &size);

  if (status == MFRC522::STATUS_OK) {
    Serial.print(F("Read character: "));
    Serial.println((char)data[0]);
    return (char)data[0];
  }
  else{
    return 'Z';
  }
}




void CheckButtons(){
 
  for( int y = 0; y < yellowArrayLength; y++){
    //turn it all off
    digitalWrite(yellowArray[y], LOW);
  }
  for( int y = 0; y < yellowArrayLength; y++){
    //loop through yellow
    digitalWrite(yellowArray[y], HIGH);
    for (int b = 0; b <blueArrayLength; b++){
      //loop through blue
      if(analogRead(blueArray[b])> 800){
      //  Serial.println(analogRead(blueArray[b]));
        Serial.println(y);
        Serial.print("\t");
        int val = (y*2)+b+1;
        tokenLocation = val;
        if(val != 0 ){
          Serial.println(val);
          return;
        }
       
        // Serial.println(val);
      }
     

    }
     
  }

}
Here are images of the work:




Here is an image of a multiplexer I couldn't get to use:


Here is the video:
https://youtu.be/bsAVMdYXNWQ

TinkerCad Link:
https://www.tinkercad.com/things/k8BHwkSJki4-magnificent-turing?sharecode=sF5BDK-GbTyRxx2Q33Wk7OspcDOm5Wo95juOC4Vkp1c









No comments:

Post a Comment

Note: Only a member of this blog may post a comment.