I am trying to communicate to my arduino with Visual studio C #, everything is fine, the only thing I can not get is that the program recognizes my int as a string, even though I already added the .tostring () to it. here the program that I have been doing so far.
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SerialPort1.Open();
}
private void Port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
string Puerto = ("SerialPort1.ReadLine()").ToString();
if (Puerto = 0) {
MessageBox.Show("El valor actual es de 0");
}
else if (Puerto = 1) {
MessageBox.Show("El valor actual es de 1");
}
else if (Puerto = 2) {
MessageBox.Show("El valor actual es de 2");
}
else if (Puerto = 3) {
MessageBox.Show("El valor actual es de 3");
}
}
}
}
thanks in advance.