Arduino basic:How to get sub string from a string in arduino

ArduinoTutorial 01:String manipulation 1
(Getting substring from a large string)

hello, everyone in some cases we need small parts of the string to manipulate. here substring and index function play an important role.

I am providing example code in this blog 

String IP = "111.222.333.444";int FIRST_INDEX;int SECOND_INDEX;int THIRD_INDEX;void setup() {Serial.begin(9600);FIRST_INDEX=IP.indexOf(".");SECOND_INDEX=IP.indexOf(".",FIRST_INDEX+1);THIRD_INDEX=IP.indexOf(".",SECOND_INDEX+1 );Serial.print(IP.substring(0,FIRST_INDEX));Serial.print(IP.substring(FIRST_INDEX+1,SECOND_INDEX));
Serial.print(IP.substring (SECOND_INDEX+1 ,THIRD_INDEX ));
}void loop() {  // put your main code here, to run repeatedly: }



https://youtu.be/fjVXhcqWlEM......watch more videos related to Aduino Assistance



Comments

Popular posts from this blog

Analog input Analog output of arduino