how to keep data comming from Arduino serial written in VB.NET TextBox
up vote
-1
down vote
favorite
I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?
Arduino Code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
delay(5000);
}
and the code in VB.NET is :
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text
Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"
Using con As New MySqlConnection(str)
Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)
con.Open()
Dim rd As MySqlDataReader = cm.ExecuteReader()
' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")
MessageBox.Show("small")
ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")
MessageBox.Show("big")
ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")
MessageBox.Show("Mid")
End If
End If
End Using
End Sub
and the code for serial connection in VB.NET:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
vb.net arduino-uno
add a comment |
up vote
-1
down vote
favorite
I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?
Arduino Code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
delay(5000);
}
and the code in VB.NET is :
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text
Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"
Using con As New MySqlConnection(str)
Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)
con.Open()
Dim rd As MySqlDataReader = cm.ExecuteReader()
' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")
MessageBox.Show("small")
ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")
MessageBox.Show("big")
ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")
MessageBox.Show("Mid")
End If
End If
End Using
End Sub
and the code for serial connection in VB.NET:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
vb.net arduino-uno
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?
Arduino Code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
delay(5000);
}
and the code in VB.NET is :
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text
Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"
Using con As New MySqlConnection(str)
Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)
con.Open()
Dim rd As MySqlDataReader = cm.ExecuteReader()
' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")
MessageBox.Show("small")
ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")
MessageBox.Show("big")
ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")
MessageBox.Show("Mid")
End If
End If
End Using
End Sub
and the code for serial connection in VB.NET:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
vb.net arduino-uno
I am sending data from arduino to VB.NET app like rfid number to be shown in TextBox3.Text the data transfered without any problem but after showing in TextBox3.text then removed from textbox and i want it to be in textbox no delete it until I delete it. How can I achieve this?
Arduino Code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
delay(5000);
}
and the code in VB.NET is :
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
TextBox2.Text = TextBox3.Text
Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password"
Using con As New MySqlConnection(str)
Dim query As String = "select * from testdatawhere rfid_tag='" & TextBox3.Text & "'
and Date_Operation<= '" & Date.Now.ToString("yyyy-MM-dd ") & "'
and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "'
and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "'
or spring_size='' " 'Note:TextBox3 is the RFID number come from RFID arduino
Dim cm As New MySqlCommand(query, con)
con.Open()
Dim rd As MySqlDataReader = cm.ExecuteReader()
' Check if any rows exist
If rd.Read() Then
If rd.GetString(3) = "small" Then
SerialPort1.Write("1")
MessageBox.Show("small")
ElseIf rd.GetString(3) = "Big" Then
SerialPort1.Write("2")
MessageBox.Show("big")
ElseIf rd.GetString(3) = "Midium" Then
SerialPort1.Write("3")
MessageBox.Show("Mid")
End If
End If
End Using
End Sub
and the code for serial connection in VB.NET:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
vb.net arduino-uno
vb.net arduino-uno
asked yesterday
Mohammad Khaled
468
468
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday
add a comment |
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
the issue was in this code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
the correct like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData
End Sub
I missed &
to put it before =
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
the issue was in this code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
the correct like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData
End Sub
I missed &
to put it before =
add a comment |
up vote
0
down vote
the issue was in this code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
the correct like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData
End Sub
I missed &
to put it before =
add a comment |
up vote
0
down vote
up vote
0
down vote
the issue was in this code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
the correct like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData
End Sub
I missed &
to put it before =
the issue was in this code
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData = ReceiveSerialData()
TextBox3.Text = receivedData
End Sub
the correct like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
receivedData &= ReceiveSerialData()
TextBox3.Text &= receivedData
End Sub
I missed &
to put it before =
answered yesterday
Mohammad Khaled
468
468
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372615%2fhow-to-keep-data-comming-from-arduino-serial-written-in-vb-net-textbox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm not sure I understand your requirement, but try with TextBox3.Appendtext( receivedData)
– Alessandro Mandelli
yesterday