Communicate Arduino with Visual studio

Hi, so i need to make a project that combines Arduino and Visual studio (c#).

(FYI - i'm a total beginner).

What i need to do is to send a bunch of numbers and letters from the Visual studio to the Arduino program, and when the Arduino recognizes that it received that data (or any data) it will print it on the LCD.

For an example:

If i send - ("h1b2b6e3f");

than the Arduino will print "You Received h1b2b6e3f " on the lcd.

That's the code iv'e written so far in both programs :

Arduino[/b]
char data;
#include <LiquidCrystal.h>
LiquidCrystal lcd (53,51,49,47,45,43);
void setup() {
lcd.begin (16,2);
Serial.begin(9600);
}
void loop() {
lcd.setCursor (0,0);
if (Serial.available())
{
** data = Serial.read();**
** if (data == 'A')**
** {**
** lcd.clear();**
** lcd.print ("You Pressed");**
** lcd.setCursor (0,1);**
** lcd.print ("'Write'");**
** }**
** if (data == 'B')**
** {**
** lcd.clear(); **
** }**
** else**
** {**
** lcd.clear(); **
** lcd.print ("You Recieved");**
** lcd.setCursor(0,1);**
** lcd.print (data);**
** }**
** }**
}
Visual studio
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
** public partial class Form1 : Form**
** {**
** public Form1()**
** {**
** InitializeComponent();**
** serialPort1.Open();**
** }**
** private void button1_Click(object sender, EventArgs e)**
** {**
** serialPort1.Write("A");**
** }**
** private void button2_Click(object sender, EventArgs e)**
** {**
** serialPort1.Write("B");**
** }**
** private void button3_Click(object sender, EventArgs e)**
** {**
** serialPort1.Write("C");**
** }**
** }**
}
I will really appreciate your help! No one else in my country can help me sadly :frowning:

I will really appreciate your help!

With what? You post some code, incorrectly. You explained what you expect to happen, but you did not explain what actually happens.

No one else in my country can help me sadly

I can not believe that NO ONE in your country could help you, IF you provided enough details.

By the way, your thread title is completely wrong. Visual Studio can not communicate with the Arduino, because it does NOT write to, or read from, any serial port. Visual Studio is an application for developing applications that can communicate with a serial port.

I suggest that you start simple and write and ebug the Arduino code and use serial monitor. Once you have that bug free, develop your C# side of things.

Maybe serial port class will help with the windows side of things.

PaulS:
With what? You post some code, incorrectly. You explained what you expect to happen, but you did not explain what actually happens.
I can not believe that NO ONE in your country could help you, IF you provided enough details.

By the way, your thread title is completely wrong. Visual Studio can not communicate with the Arduino, because it does NOT write to, or read from, any serial port. Visual Studio is an application for developing applications that can communicate with a serial port.

Ok, so what actually happens is that i send to the Arduino the char 'C' and it says in the LCD :
" You received C".

now i want it to print : "You received (and here is the data i send to the arduino)".

My problem is that i don't know how to send the data i want. i want to send something like
: "5,8,g,y,2,b,9,k,z".

and whenever the Arduino receives the letter 'C', it will print the data, which is - 5,8,g,y,2,b,9,k,z

Ok, so what actually happens is that i send to the Arduino the char 'C' and it says in the LCD :
" You received C".

So, you know that communication happens correctly.

now i want it to print : "You received (and here is the data i send to the arduino)".

You are already doing that, one character at a time. Am I missing something?

My problem is that i don't know how to send the data i want

From the Arduino or from the PC?

i want to send something like

To?

PaulS:
So, you know that communication happens correctly.
You are already doing that, one character at a time. Am I missing something?
From the Arduino or from the PC?
To?

Yes, i am already sending the data i want, but one character at a time.
What i want to do is send an array of characters, and for some reason it doesn't let me.

And what i want to send is something like "5,8,g,y,2,b,9,k,z", from the visual studio (C#), to the Arduino
(the program on the pc).

What i want to do is send an array of characters, and for some reason it doesn't let me.

It? Is "it" the pickle on your hamburger?

The application developed using Visual Studio CAN send an array of characters. The Arduino can receive an array of characters, but not with the code that you have.

And what i want to send is something like "5,8,g,y,2,b,9,k,z", from the visual studio (C#), to the Arduino
(the program on the pc).

The Arduino is not the program on the PC.

See this thread: Serial Input Basics - updated - Introductory Tutorials - Arduino Forum

It's very difficult to determine what you're stuck with.

For the VisualStudio side of things, you're already sending a string when you press a button; so what stops you from sending e.g. "Bsome text" when you click button 'B' or "Csome other text" when you press button 'C'?

Next you should read Serial Input Basics - updated to get an idea how to (in general) approach text-based serial communication. It describes some protocols (for you to pick). The first one determines the end of a message based on the newline character, the second one uses a start and end marker.

Be aware that if you opt for the first one, you basically have to use something like "Bsome text\n"

PaulS:
It? Is "it" the pickle on your hamburger?

The application developed using Visual Studio CAN send an array of characters. The Arduino can receive an array of characters, but not with the code that you have.
The Arduino is not the program on the PC.

See this thread: Serial Input Basics - updated - Introductory Tutorials - Arduino Forum

I really appreciate your help, But as i said, i'm just a beginner (1 month) and it seems like you don't want to help me so i would like it if you stop commenting, THANK YOU for your help so far.