Robert Korn
Published © MIT

Arduino Serial Port Shield for Linkit One

A Legacy Serial Port

BeginnerShowcase (no instructions)2,166
Arduino Serial Port Shield for Linkit One

Things used in this project

Hardware components

max232 IC
×1
1uF Capacitor
×5
DB-9 Connector
×1
Arduino Proto Shield
Arduino Proto Shield
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Almost verbatim from the data sheet

Code

Serial Test Terminal

Arduino
This is just the Software Serial Demo remixed for the Linkit One's serail1 port
//****************************************************************
//*  Name    : Serial Demo                                       *
//*  Author  : Robert Joseph Korn                                *
//*  Date    : 12/14/15                                          *
//*  Version : 1.1                                               *
//*  Notes   : Really just the software serial demo              *
//*          : changed for serial1                               *
//****************************************************************

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

 Serial1.begin(9600);
}

void loop() { 
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }
  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
}

Mag Stripe Reader Demo

Arduino
Simple Magtek Serial Swipe ReaderDemo
//****************************************************************
//*  Name    : Serial Mag Swipe Reader Demo                      *
//*  Author  : Robert Joseph Korn                                *
//*  Notice  : Copyright (c) 2015 Open Valley Consulting Corp    *
//*  Date    : 12/14/15                                          *
//*  Version : 1.1                                               *
//*  Notes   :                                                   *
//*          :                                                   *
//****************************************************************

int SER = 0;
int state = 0;
int numlen=0;
int namlen=0;
int o=0;
char nam[255];
char num[55];

void setup() {
  
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial1.begin(9600);

//  Serial1.write((int)0x07); // Boot Message
  Serial1.write((int)0x0C); // Clear Message
  Serial1.println();
  Serial1.write((int)0x0F);
  Serial1.println("MediaTek Linkit One");
  Serial.println("MediaTek Linkit One");
  Serial1.write((int)0x0E);
  Serial1.println("Mag Swipe Read Demo");
  Serial.println("Mag Swipe Read Demo");
  Serial.println("");
 delay(500);

}

void loop() {
   
          if( state == 3 ) 
          {     
              Serial1.write((int)0x0C);
             Serial.print("Track 1: ");
              
            for(int o=0;o<namlen-1;o++)
             {
               Serial1.print(char(nam[o]));             
               Serial.print(char(nam[o]));             
             }
             
             Serial1.println("");
             Serial.println("");
             Serial1.write((int)0x0E);
             Serial.print("Track 2: ");
 
             for(int o=0;o<numlen-1;o++)
             {
               Serial1.print(char(num[o]));             
               Serial.print(char(num[o]));             
             }
             
             Serial1.println("");
             Serial.println("");
             Serial.println("");

            numlen=0;
            namlen=0;
            state=0;     
          }
  
  if (Serial1.available() > 0) {
      SER = Serial1.read(); 

  switch(state)
  {
    case 0:if (SER==0x3B)  
               {
                 state=1;
               }
           if (SER==0x25)  
               {
                 state=2;
               }break;
               
    case 1:num[numlen]=SER;  
            numlen++;             
              if (SER==0x3F)  
               {
                 state=3;
               }break;
               
    case 2:nam[namlen]=SER;  
            namlen++;              
              if (SER==0x3F)  
               {
                 state=0;
               }break;
          
     default:break;
  }
 
  }

}

Credits

Robert Korn

Robert Korn

15 projects • 27 followers
I Made the Internet of Things before people had a name for it.

Comments