Hall Pass Project questions (uses Seven Segment display and NFC Sheild).

Hello, I am new to Arduino and am having some problems with my project. I planned on making a electronic hall pass of sorts, but I have run into complications. My project consists of 2 connected seven segment displays that should count down from 5 minutes when the arduino is removed from PN532 RFID/NFC Shield. It should display a 5 for a minute, then a 4 for a minute, then a 3 and so on until the countdown reaches 1. Then, the 1 becomes 60 and the display counts down from 60 seconds. So it should display a 60 for a sec, a 59, 58, 57, etc for a sec until it reaches zero. Once it reaches 0, then a buzzer will sound telling the student using the hall pass that their time is up. The count down will start over to 5 minutes when the arduino is connected again to the shield card (which will be kept in the classroom) and stay at 5 minutes until it is removed again.

So, when I first wrote the countdown code, the display and the countdown worked perfectly (I wrote it without the shield code). When I added the shield code, though, the display started displaying weird patterns on the segments on the display. My teacher and I have searched the code and nothing seems wrong, but one line of code makes the display act weird. The line is under the void loop code and it reads:

success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

This defines what success is and the if statement deals with success to determine whether or not it should count down, so I’m not sure what’s wrong with my code. If anyone can help me with this and tell me what is wrong and how to fix the display I would really appreciate it. I’m pretty nervous about finishing my project on time since it’s for a grade. I’m the only girl is a programming class with all boys so I want my project to be better than theirs. :grinning: Please let me know if you figure anything out. I will paste my code below and put some pics of my projects in (I’m pretty sure the error does not lie in the wiring). Also, I have a small error on the display where one segment won’t turn off. I plan on fixing that later when the actual countdown code actually works so just ignore that. Thank you!!!

My Code: */

//Library
#include <Wire.h>
#include <SPI.h>
#include “SevSeg.h”
// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
SevSeg sevseg; //Instantiate a seven segment controller object
#define IRQ (2)
#define RESET (3) // Not connected by default on the NFC Shield
#include <Adafruit_PN532.h>

boolean flag = true;

// Or use this line for a breakout or shield with an I2C connection:
Adafruit_PN532 nfc(IRQ, RESET);

//reset function called when pass returned to card
void(* resetFunc) (void) = 0;//declare reset function at address 0 THIS IS WHERE IT SHOULD RESET THE TIMER

const int buzzer = 5; //buzzer - arduino pin 5 MAKE SURE TO REASTABLISH THIS WHEN WORKING FOR THE BUZZER!!!

void setup() {

//---------------START ALL 7SEG SETUP---------------
byte numDigits = 2;
byte digitPins = {14,4}; //14 instead of 0 if no work
byte segmentPins = {10,9,8,7,6,11,12};
bool resistorsOnSegments = false; // ‘false’ means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options
bool updateWithDelays = false; // Default. Recommended
bool leadingZeros = false; // Use ‘true’ if you’d like to keep the leading zeros

sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros);
sevseg.setBrightness(90);
//---------------END ALL 7SEG SETUP---------------

Serial.begin(115200);
Serial.println(“Hello!”);

//---------------START ALL NFC SETUP---------------
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print(“Didn’t find PN53x board”);
while (1); // halt
}
// IF we have data, print it out!
Serial.print(“Found chip PN5”);
Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. ");
Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print(’.’);
Serial.println((versiondata>>8) & 0xFF, DEC);

//Set the max number of retry attempts to read from a card
//This prevetns us from waiting forever for a card, which is
//the default behavior of the PN532
//nfc.setPassiveActivationRetries(0x1);

// configure board to read RFID tags
nfc.SAMConfig();

Serial.println(“Waiting for an ISO14443A Card …”);

//---------------END ALL NFC SETUP---------------

}

void loop(){
static int minutesCount = 0;
static unsigned long timer= millis() ;
static int sixtySec = 06; //comment out

uint8_t success;
uint8_t uid = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
uint16_t timeout;
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// ‘uid’ will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

if (millis() >= timer) {
sixtySec --;

//set timer count by minute or second
if (minutesCount == 0) {
timer += 60000;//coment out
}
else if (minutesCount == 1){
timer += 1000;
}

if (sixtySec == 1 and minutesCount == 0) {
minutesCount += 1;
sixtySec = 60;
}
else if (sixtySec <= 0 and minutesCount == 1) {
sixtySec = 0;
tone(buzzer,600); //play tone
delay(1000);

noTone(buzzer);
delay(1000);
}
sevseg.setNumber(sixtySec, 0);

Serial.println(sixtySec);
}

sevseg.refreshDisplay(); // Must run repeatedly
}

I attached a picture of the 5 when its counting down (the success line is commented out). I also so attracted a picture of the countdown when the line isn’t commented out and it countdowns strangely.

Thank you for reading my post!