Connecting an arduino and an isolated PC carrying VB program via EthernetShield

Hi Everyone!

I have an arduino Uno and an ethernet shield.

I am making a VB program that communicates with the arduino uno COM Port, the VB program and the Arduino hardware is installed in the same PC.

The VB Program is intended to control (turn ON/OFF) the LEDs connected to the arduino.
When I click an LED ON button at the VB Program, it sends data to the arduino in a form of ASCII Character, and then upon reception, the Arduino converts it into a decimal value for it to understand and turn the specific LED On or OFF .

The VB Program must also know the Arduino's COM Settings such as com Port, Baud Rate, Handshake, Stop Bits , DATA bits etc. for it to connect with the arduino
like this:

 SerialPort1.PortName = ("COM23")
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None

Attached below is the VB Code
And here is the Arduino Code

int f =0;


const byte led5 = 5;
const byte led6 = 6;
const byte led7 = 7;
const byte led8 = 8;
const byte led9 = 9;
const byte led10= 10;



//-------------------------------------------
void setup() 
  {
   Serial.begin(9600);    
  
   pinMode(led5,OUTPUT); //LED 5 
   pinMode(led6,OUTPUT); //LED 6
   pinMode(led7,OUTPUT); //LED 7
   pinMode(led8,OUTPUT); //LED 8
   pinMode(led9,OUTPUT); //LED 9
   pinMode(led10,OUTPUT); //LED 10
  
   
}
//-------------------------------------------
void loop() {
  
 if (Serial.available()>0){
    
    f=Serial.read();



/
     if (f==53) { //53 (DEC) = 5 (ASCII character)
       digitalWrite(led5,HIGH);
       Serial.flush(); 
     }
   
     if (f==54) { //54 (DEC) = 6 (ASCII character)
       digitalWrite(led5,LOW);
       Serial.flush(); 
     }
     
    
     if (f==55) { //55 (DEC) = 7 (ASCII character)
       digitalWrite(led6, HIGH);
       Serial.flush(); 
     }
   
     if (f==56) { //56 (DEC) = 8 (ASCII character)
       digitalWrite(led6,LOW);
       Serial.flush();
     }
     


     if (f==65) { //53 (DEC) = 5 (ASCII character)
       digitalWrite(led7,HIGH);
       Serial.flush(); 
     }
   
     if (f==66) { //54 (DEC) = 6 (ASCII character)
       digitalWrite(led7,LOW);
       Serial.flush(); 
     }
     
///////////////////////////////////////////////////////
  if (f==67) { //53 (DEC) = 5 (ASCII character)
       digitalWrite(led8,HIGH);
       Serial.flush(); 
     }
   
     if (f==68) { //54 (DEC) = 6 (ASCII character)
       digitalWrite(led8,LOW);
       Serial.flush(); 
     }
     
 ///////////////////////////////////////////////////////
  if (f==69) { //53 (DEC) = 5 (ASCII character)
       digitalWrite(led9,HIGH);
       Serial.flush(); 
     }
   
     if (f==70) { //54 (DEC) = 6 (ASCII character)
       digitalWrite(led9,LOW);
       Serial.flush(); 
     }


///////////////////ALL   ON   ///////////////////////

// Blink End ----------------------------------|   
// Switch All ON Start ------------------------|
    if (f==50) { //50 (DEC) = 2 (ASCII character)
   
       digitalWrite(led5,HIGH);
       digitalWrite(led6,HIGH);
       digitalWrite(led7,HIGH);
       digitalWrite(led8,HIGH);
       digitalWrite(led9,HIGH);
       digitalWrite(led10,HIGH);

       Serial.flush();
       
     }

//////ALL OFF  //////////////

     if (f==51) { //51 (DEC) = 3 (ASCII character)
 
       digitalWrite(led5,LOW);
       digitalWrite(led6,LOW);
       digitalWrite(led7,LOW);
       digitalWrite(led8,LOW);
       digitalWrite(led9,LOW);
       digitalWrite(led10,LOW);


       Serial.flush();
     }
// Switch All OFF End ------------------------|
   }
}

These two programs are working perfectly.
HOWEVER,

I am going to need to separate the Arduino Uno and the PC-carrying the VB Program, however in the same network.

That is,
I connect the Arduino Uno + Ethernet Shield combination directly to our network switch, and then I connect a laptop-carrying the VB Program also to the same network switch. But the Arduino is not connected to the laptop by usb or uart.

My question is, How can I connect the Laptop Carrying the VB Program to the Arduino via ethernet shield im the same network without connecting the arduino to the Laptop's serial/com ports?

Can the isolated arduino have something like a Virtual COM Port so that I can input it to my VB Program?

Thank you guys in advance .

VB PROGRAM.txt (15.8 KB)

My question is, How can I connect the Laptop Carrying the VB Program to the Arduino via ethernet shield im the same network without connecting the arduino to the Laptop's serial/com ports?

If the Arduino with ethernet shield is a server, any client can make GET requests to it. The VB app would be a client.

If the Arduino with ethernet shield is a client, it can make GET requests to any server. The VB app would then be a server. (Good luck with making that happen.)

So, what role should the Arduino play?

The arduino holds all the LEDs to be controlled by the VB program. I send a command via VB to the arduino, then the arduino follows the command.

Is there any way where I can assign a virtual com port to the arduino so that I can detect it in the same network even with different pc?

Is there any way where I can assign a virtual com port to the arduino so that I can detect it in the same network even with different pc?

Assign a virtual com port where? On the router? No.

A com port is a PC thing. If the Arduino is connected to another PC, your laptop need to talk to some application running on that PC, and that application needs to talk to the com port that the Arduino is connected to.

If the Arduino is not connected to another PC, there is no way to have a com port.

Does it have to be via ethernet?
If you were just looking to go wireless with a basic max range of around 300ft you could pick up some XBee's (more XBee info here). They communicate serially so you wouldn't have to change the code.

It has to be via ethernet :confused:

Write a VB program that uses TCP/IP or UDP.