Pages: [1]   Go Down
Author Topic: magnetic card reader with lcd  (Read 778 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm trying to make magnetic card reader which reads track1 & track2. I'm using this code http://code.google.com/p/magstripelib/ to read tracks, but the problem is that I can only read 1 track. I need to read both tracks. My skills ends here, but I think that I can write that code if somebody can help me with the beginning. I also need lcd to display data from cards, but I think that I can do it myself smiley Thanks for help!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49101
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but the problem is that I can only read 1 track.
The example contains this:
Code:
  // Initialize the library for reading track 1...
  card.begin(1);

What does your code contain to read track 2?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but the problem is that I can only read 1 track.
The example contains this:
Code:
  // Initialize the library for reading track 1...
  card.begin(1);

What does your code contain to read track 2?

Oup, sorry. I mean that I can only read track 1 or track 2 at one time. I'm using that example code provided with that library. I need to read track 1 and 2 at same time.

Code:
/*
 * MagStripeReader - Read data from a magnetic stripe card (track 1, 2 or 3).
 *
 * Copyright (c) 2010 Carlos Rodrigues <cefrodrigues@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


#include <MagStripe.h>


// Visual feedback when the card is being read...
static const byte READ_LED = 13;
static const byte ERROR_LED = 12;

MagStripe card;

/*
 * Track 3 is the one that can contain the most characters (107).
 * We add one more to accomodate the final '\0', as the data is a C string...
 */
static const byte DATA_BUFFER_LEN = 108;
static char data[DATA_BUFFER_LEN];


void setup()
{
  pinMode(READ_LED, OUTPUT);
  pinMode(ERROR_LED, OUTPUT);
 
  // The card data will be sent over serial...
  Serial.begin(9600);
 
  // Initialize the library for reading track 1...
  card.begin(1);

  // Start with the feedback LEDs off...
  digitalWrite(READ_LED, LOW);
  digitalWrite(ERROR_LED, LOW);
}

 
void loop()
{
  // Don't do anything if there isn't a card present...
  if (!card.available()) {
    return;
  }
 
  // Show that a card is being read...
  digitalWrite(READ_LED, HIGH);
 
  // Read the card into the buffer "data" (as a null-terminated string)...
  short chars = card.read(data, DATA_BUFFER_LEN);
 
  // Show that the card has finished reading...
  digitalWrite(READ_LED, LOW);
 
  // If there was an error reading the card, blink the error LED...
  if (chars < 0) {
    digitalWrite(ERROR_LED, HIGH);
    delay(250);
    digitalWrite(ERROR_LED, LOW);

    return;
  }

  // Send the data to the computer...
  Serial.println(data);
}


/* EOF - MagStripeReader.pde */
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just examined code bit more, and I see that it uses 2 Interrupt. And arduino UNO has only 2 interruptus, so I need 2 more. I tried to change "MAGSTRIPE_RDT" pin (data pin) to D7 with adding new interrupt using this tutorial: http://www.me.ucsb.edu/~me170c/Code/How_to_Enable_Interrupts_on_ANY_pin.pdf

But it didn't work. I used this code:
Code:
  PCICR |= (1<<PCIE2);
PCMSK2 |= (1<<PCINT23);
MCUCR = (1<<ISC01) | (1<<ISC00);

And I have edited that interrupt pin on file named: MagStripe.cpp (Old interrupt pin: 0, I tried with pin 5). Please help, I really need to get this work. Thanks.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Up!
Logged

Pages: [1]   Go Up
Jump to: