how to split a string message and access the sensors values

(Last Updated On: July 6, 2019)

split a string message

Description:

In this tutorial, You learn how you can send multiple values from Arduino to Visual Basic application in one message and then how to split a string message and access each value separately. In this project, we will be using a comma”, ” as the delimiter.

To explain this we will be making An application in vb.net ” visual basic .net ” to receive a message and then split the message using the split function.

This tutorial will really help you in designing advanced level projects, in which multiple sensors are monitored. Read this post or watch Video given at the end of this Article from start to the very end to learn how you can split a string and access the sensors values sent from the Arduino to visual basic application. The programming languages used are

  1. visual basic 2010 express edition and
  2. Arduino Uno IDE.

The Arduino programming is done in c language.This tutorial will cover the application designing, complete circuit diagram explanation, LDR and variable resistor interfacing, controller programming, and testing.


The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
12v 10A SPDT relay: https://amzn.to/2MThQBK
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF


About the LDR:

split a string message

LDR stands for “LIGHT DEPENDENT RESISTOR”. LDR is basically a resistor whose resistance changes with the amount of light falling on the LDR. As the light intensity increases the resistance decreases. While with the decrease in light intensity the resistance increases. So we can say that an LDR is a variable resister, whose resistance is controlled by the light.

The Basic working principle of the LDR is just like the ordinary resistor. Unlike other resistors the LDR also has no polarity, so it doesn’t matter how you connect the two legs of the LDR. In this project the Variable resistor will be used in series with another 10k resistor. So the LDR and the 10k resistor will make a voltage divider. The voltage at the middle of the LDR and 10k resistor will change as the light changes.


The output of the voltage divider circuit will be connected with the analog pin of the Arduino or Mega. Then using the arduino programming we read the value of the LDR and combine this value with the value of the variable resistor and then send the complete message to the computer application, where these values will be split and displayed in desired boxes.

Programming:

Arduino Programming:

The textForSMS variable which is of the type String will be used for making a complete message consisting  of the LDR and variable resistor values separated by comma. Then I defined another variable of the type integer “ldr” and assigned it to the analog pin A1 of the Arduino. now we will refer to the analog pin A1 as the ldr. From now on ldr will be the name of the A1. Similarly defined pin A2 and assigned a name vresistor. Then I defined two variables of the type integer ldata and vdata.

As you know my friends every Arduino and Mega Program has at least two functions which are the void step and void loop functions. Void means that these functions are not returning any values, while the empty parenthesis means that these functions are not taking any arguments as the input. To establish the serial communication, I activated the serial communication using the Serial.begin() function and set the baud rate to 9600. This is the communication speed. Then I set the ldr and variable resistor as the input. One more thing about the void setup function is that, it executes only one time when the arduino or mega board is powered up.


In the void loop we read both the sensors “ LDR and vresistor “ and store the values in variables ldata and vdata. Then we add both the values with comma’s as the separators and store this in variable textForSMS. Then using the serial.println() function we send this message to the computer application. Finally we empty the string and use a delay of 1000 milli seconds which is equal to one second.  The comma is used as the delimiter which will be used to split a string message sent to the computer application.



Computer application designing and programming for split a string message:

Watch Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

1 Comment

Leave a Reply

Close