Adding to project MagSpoof

So my plan is to add onto the work of Samy Kamkar. He created a device called the MagSpoof that would emulate a mag-stripe card at point of sale system. I would like to have more than one card stored on the device I have added more input pins and set their pin mode and set new char values but I'm not that familiar with C. In the void loop section I am trying to make a pin set low to change the char value of tracks[] . Any help or ideas help .

/*
 * MagSpoof - "wireless" magnetic stripe/credit card emulator
*
 * by Samy Kamkar
 *
 * http://samy.pl/magspoof/
 *
 * - Allows you to store all of your credit cards and magstripes in one device
 * - Works on traditional magstripe readers wirelessly (no NFC/RFID required)
 * - Can disable Chip-and-PIN (code not included)
 * - Correctly predicts Amex credit card numbers + expirations from previous card number (code not included)
 * - Supports all three magnetic stripe tracks, and even supports Track 1+2 simultaneously
 * - Easy to build using Arduino or ATtiny
 *
 */
#include <avr/sleep.h>
#include <avr/interrupt.h>

#define PIN_A 0
#define PIN_B 1
#define ENABLE_PIN 3 // also green LED
#define SWAP_PIN 4 // unused
#define BUTTON_PIN 2 // Send Tracks
#define CLOCK_US 200
#define BETWEEN_ZERO 53 // 53 zeros between track1 & 2
#define TRACKS 2
/*New Varables*/

#define PINCARD1 8
#define PINCARD2 9
#define PINCARD3 10

// consts get stored in flash as we don't adjust them
const char* CARD1[] = 
{
"%Card1^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?\0", // Track 1
";123456781234567=YYMMSSSDDDDDDDDDDDDDD?\0" // Track 2
};

const char* CARD2[] = 
{
"%Card2^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?\0", // Track 1
";123456781234567=YYMMSSSDDDDDDDDDDDDDD?\0" // Track 2
};

const char* CARD3[] = 
{
"%Card3^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?\0", // Track 1
";123456781234567=YYMMSSSDDDDDDDDDDDDDD?\0" // Track 2
};

/*
const char* tracks[] = 
{
"%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?\0", // Track 1
";123456781234567=YYMMSSSDDDDDDDDDDDDDD?\0" // Track 2
};
*/

char revTrack[41];

const int sublen[] = {
  32, 48, 48 };
const int bitlen[] = {
  7, 5, 5 };

unsigned int curTrack = 0;
int dir;

void setup()
{
  pinMode(PIN_A, OUTPUT);
  pinMode(PIN_B, OUTPUT);
  pinMode(ENABLE_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  
  pinMode(PINCARD1, INPUT_PULLUP);
  pinMode(PINCARD2, INPUT_PULLUP);
  pinMode(PINCARD3, INPUT_PULLUP);
  
  // blink to show we started up
  blink(ENABLE_PIN, 200, 3);

  // store reverse track 2 to play later
  storeRevTrack(2);
}

void blink(int pin, int msdelay, int times)
{
  for (int i = 0; i < times; i++)
  {
    digitalWrite(pin, HIGH);
    delay(msdelay);
    digitalWrite(pin, LOW);
    delay(msdelay);
  }
}

// send a single bit out
void playBit(int sendBit)
{
  dir ^= 1;
  digitalWrite(PIN_A, dir);
  digitalWrite(PIN_B, !dir);
  delayMicroseconds(CLOCK_US);

  if (sendBit)
  {
    dir ^= 1;
    digitalWrite(PIN_A, dir);
    digitalWrite(PIN_B, !dir);
  }
  delayMicroseconds(CLOCK_US);

}

// when reversing
void reverseTrack(int track)
{
  int i = 0;
  track--; // index 0
  dir = 0;

  while (revTrack[i++] != '\0');
  i--;
  while (i--)
    for (int j = bitlen[track]-1; j >= 0; j--)
      playBit((revTrack[i] >> j) & 1);
}

// plays out a full track, calculating CRCs and LRC
void playTrack(int track)
{
  int tmp, crc, lrc = 0;
  track--; // index 0
  dir = 0;

  // enable H-bridge and LED
  digitalWrite(ENABLE_PIN, HIGH);

  // First put out a bunch of leading zeros.
  for (int i = 0; i < 25; i++)
    playBit(0);

  //
  for (int i = 0; tracks[track][i] != '\0'; i++)
  {
    crc = 1;
    tmp = tracks[track][i] - sublen[track];

    for (int j = 0; j < bitlen[track]-1; j++)
    {
      crc ^= tmp & 1;
      lrc ^= (tmp & 1) << j;
      playBit(tmp & 1);
      tmp >>= 1;
    }
    playBit(crc);
  }

  // finish calculating and send last "byte" (LRC)
  tmp = lrc;
  crc = 1;
  for (int j = 0; j < bitlen[track]-1; j++)
  {
    crc ^= tmp & 1;
    playBit(tmp & 1);
    tmp >>= 1;
  }
  playBit(crc);

  // if track 1, play 2nd track in reverse (like swiping back?)
  if (track == 0)
  {
    // if track 1, also play track 2 in reverse
    // zeros in between
    for (int i = 0; i < BETWEEN_ZERO; i++)
      playBit(0);

    // send second track in reverse
    reverseTrack(2);
  }

  // finish with 0's
  for (int i = 0; i < 5 * 5; i++)
    playBit(0);

  digitalWrite(PIN_A, LOW);
  digitalWrite(PIN_B, LOW);
  digitalWrite(ENABLE_PIN, LOW);

}



// stores track for reverse usage later
void storeRevTrack(int track)
{
  int i, tmp, crc, lrc = 0;
  track--; // index 0
  dir = 0;

  for (i = 0; tracks[track][i] != '\0'; i++)
  {
    crc = 1;
    tmp = tracks[track][i] - sublen[track];

    for (int j = 0; j < bitlen[track]-1; j++)
    {
      crc ^= tmp & 1;
      lrc ^= (tmp & 1) << j;
      tmp & 1 ?
        (revTrack[i] |= 1 << j) :
        (revTrack[i] &= ~(1 << j));
      tmp >>= 1;
    }
    crc ?
      (revTrack[i] |= 1 << 4) :
      (revTrack[i] &= ~(1 << 4));
  }

  // finish calculating and send last "byte" (LRC)
  tmp = lrc;
  crc = 1;
  for (int j = 0; j < bitlen[track]-1; j++)
  {
    crc ^= tmp & 1;
    tmp & 1 ?
      (revTrack[i] |= 1 << j) :
      (revTrack[i] &= ~(1 << j));
    tmp >>= 1;
  }
  crc ?
    (revTrack[i] |= 1 << 4) :
    (revTrack[i] &= ~(1 << 4));

  i++;
  revTrack[i] = '\0';
}

void sleep()
{
  GIMSK |= _BV(PCIE);                     // Enable Pin Change Interrupts
  PCMSK |= _BV(PCINT2);                   // Use PB3 as interrupt pin
  ADCSRA &= ~_BV(ADEN);                   // ADC off
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement

  MCUCR &= ~_BV(ISC01);
  MCUCR &= ~_BV(ISC00);       // Interrupt on rising edge
  sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
  sei();                                  // Enable interrupts
  sleep_cpu();                            // sleep

  cli();                                  // Disable interrupts
  PCMSK &= ~_BV(PCINT2);                  // Turn off PB3 as interrupt pin
  sleep_disable();                        // Clear SE bit
  ADCSRA |= _BV(ADEN);                    // ADC on

  sei();                                  // Enable interrupts
}

// XXX move playtrack in here?
ISR(PCINT0_vect) {
  /*  noInterrupts();
   while (digitalRead(BUTTON_PIN) == LOW);
   delay(50);
   while (digitalRead(BUTTON_PIN) == LOW);
   playTrack(1 + (curTrack++ % 2));
   delay(400);
   interrupts();*/

}

void loop()
{
#define tracks[]

  if (PINCARD1, LOW)
  {
    tracks[] = CARD1;
  }
  if (PINCARD2, LOW)
  {
    tracks [] = CARD2;
  }
  if (PINCARD3, LOW)
  {
    tracks[] = CARD3;
  }


  //for(int i=0;i<10;i++){playTrack(1+(curTrack++%2));delay(3000);}

  sleep();

  noInterrupts();
  while (digitalRead(BUTTON_PIN) == LOW);

  delay(50);
  while (digitalRead(BUTTON_PIN) == LOW);
  playTrack(1 + (curTrack++ % 2));
  delay(400);

  interrupts();
  //playTrack(1 + (curTrack++ % 2));
}

The original code is at:

#define tracks[]

WTF? You have GOT to explain what THIS is supposed to be doing.

  if (PINCARD1, LOW)

That is NOT what the conditional part of an if statement looks like. You've define PINCARD1 to be 8. 8 is NOT LOW. Ever.

    tracks[] = CARD1;

You can NOT assign values to an array that way. You need tracks to be a pointer, and make it point to different arrays.

Ok so what should it look like, if I knew what it was supposed to look like I would not have posted it.

Ok so what should it look like

What should what look like? If you mean "How should tracks be declared and used?", then the answer is:

char *tracks = NULL; // point to nothing
   tracks = CARD1; // point to CARD1 array
  noInterrupts();
  while (digitalRead(BUTTON_PIN) == LOW);

  delay(50);
  while (digitalRead(BUTTON_PIN) == LOW);
  playTrack(1 + (curTrack++ % 2));
  delay(400);

  interrupts();

delay() does not work with interrupts disabled.

Ok thank you very much what you commented makes more sense. I have one more question the last thing you commented

noInterrupts();
while (digitalRead(BUTTON_PIN) == LOW);

delay(50);
while (digitalRead(BUTTON_PIN) == LOW);
playTrack(1 + (curTrack++ % 2));
delay(400);

interrupts();

What did you change from the original?

What did you change from the original?

I did not change anything. I was pointing out that there are problems with the snippet I copied from your code.

This:

// XXX move playtrack in here?
ISR(PCINT0_vect) {
  /*  noInterrupts();
   while (digitalRead(BUTTON_PIN) == LOW);
   delay(50);
   while (digitalRead(BUTTON_PIN) == LOW);
   playTrack(1 + (curTrack++ % 2));
   delay(400);
   interrupts();*/

}

is an EXTREMELY bad example of programming. It never would have worked, which probably explains why the author commented out all the code in the ISR. At the moment, it does nothing.

Instead, the author moved that code lower down, where it is also guaranteed to fail:

 noInterrupts();
  while (digitalRead(BUTTON_PIN) == LOW);

  delay(50);

delay() doesn't work if interrupts are off.

Instead of "adding on to the work" you will first have to fix the errors that prevent it from functioning at all.