Giter Site home page Giter Site logo

magstripelib's Introduction

What is it?

MagStripe is an Arduino library to interface with TTL (raw) magnetic card readers. It supports reading any of the cards' possible three tracks, but not simultaneously. Most cards only contain data on tracks 1 and 2 though.

MagStripe-KDE.jpg

Card Readers

There are many brands of TTL magnetic card readers on the market, some with a fixed reading head and others with screws allowing the head to be manually positioned to choose one of the tracks. The connector comes with varying colors for each wire, but usually there are five wires with the following order and function:

  • Ground (black wire)
  • RDT/data
  • RCL/clock
  • CLS/card present
  • Power/+5V (red wire)

For more information, you can check the KDE KDR-1000 datasheet (pictured above), which can read all three tracks by repositioning the head, or the Panasonic ZU-M1121 datasheet for an example of another reader which can only read track 2 and has a different pin arrangement.

Note: This library is designed for swipe-type readers (like the one pictured above) meaning it requires the CLS pin to be active low while the card is being swiped and high otherwise. Insert-type readers usually have the CLS pin connected to a switch instead (active high when the card is fully inserted and low otherwise). This behavior is not supported by this library. Check your reader's datasheet if you're not sure how your reader behaves.

Installation

Download the latest zip file from the releases section. Then open it from the Sketch > Include Library > Add .ZIP Library... menu inside the Arduino IDE and a new "MagStripe" entry should appear in the Sketch > Include Library and File > Examples menus.

Arduino IDE

How it Works

Connect your card reader to the following digital pins of the Arduino Uno (or other arduinos based on the ATmega8/168/328 processors):

Arduino Pin Card Reader Pin
Digital Pin 2 RDT/data
Digital Pin 3 RCL/clock
Digital Pin 4 CLS/card present

The Arduino Leonardo or Arduino Micro (or other arduinos based on the ATmega32U4 processor) have a diferent interrupt pin assignment so, if you have one of these, connect the wires like this instead (swapped clock/data wires):

Arduino Pin Card Reader Pin
Digital Pin 2 RCL/clock
Digital Pin 3 RDT/data
Digital Pin 4 CLS/card present

If your reader can read multiple tracks at a time, and thus has extra sets of data and clock wires, check its datasheet and use the ones appropriate for the track you want to read.

The library has a thin interface and is very straightforward to use, just check if there is a card present before trying to read. The included MagStripeReader.ino example shows how to do it.

The read() method does the necessary validation checks and only returns data if it has been read correctly from the card. The data returned is a string with the (ASCII) full contents of the track, including the control characters.

To know about the format of data returned for each track, check the magnetic card standards reference.

magstripelib's People

Contributors

carlosefr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.