Arduino Serial communication using custom library with test in proteus

1: Download the library from here
https://drive.google.com/open?id=0B6i8YnjOiK19eS1nUWdnM19QRWM

2: Unzip file

3: Close Arduino sdk
4: Coppy the SerialData.h & SerialData.cpp file
5: Paste to arduino project folder
6: Open Arduino Project
7: Write the code

#include "SerialData.h"
String inputString = "";
boolean stringComplete = false;
SerialData sdata;
void setup() {
  Serial.begin(9600);
}

void loop() {
  //Serial.println("I am here");
  if (stringComplete) {
    String splitValue = sdata.getValueByPosition(inputString,':', 3);
    Serial.println(splitValue);
    inputString = "";
    stringComplete = false;
  }
}


void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

Comments