Use VB.NET with USB cable to control a Arduino that have a LED

I wonder how hard is that to contril Arduino with VB.NET

I have a Arduino Pro Micro that have USB connection.

It going to control a IR LED but right now I just want to control something basic like on/off LED.
So I have a button on my VB.NET project and can control the LED on Pro Micro.

I have looking around and what I understand I can but I have not find any good tutorial or code to understand how it work.

I have found this

I going to try that tomorrow but I wonder if someone else have use this control?

Thanks to ThatGuyJohn that have post a link to this page

So now I can control a LED and everything works fine

BUT I have one problem

In a another project I got I was create a Remote controll with IR
So I can controll a TV with buttons.

Now I like to combine this two project so I can turn on and off with my computer.

But nothing happend when I Push the button on my VB.NET program.

I think the problem is that both use serial?

My code is this

#include <IRremote.h>
 
IRsend irsend;
 

unsigned int PowerOn[68] = {9000,4400,600,1600,650,1600,600,1650,600,500,600,500,650,450,650,450,650,1600,650,450,650,1600,600,1650,600,1600,650,500,600,500,600,1650,600,500,600,1600,650,1600,650,1600,600,500,650,1600,600,500,600,500,650,450,650,500,600,500,600,500,600,1650,600,500,600,1650,600,1600,650,1600,650};
unsigned int Source[68] = {9000,4400,600,1650,600,1600,650,1600,650,450,650,500,600,500,600,500,600,1650,600,500,600,1650,600,1600,650,1600,600,500,650,450,650,1600,600,500,650,450,650,500,600,500,600,500,600,1650,600,500,600,500,650,450,650,1600,600,1650,600,1600,650,1600,650,450,600,1650,650,1600,600,1600,650};
 
void setup()
{
	Serial.begin(9600);
}
 
void loop() {

		while (Serial.available() == 0); 
		int val = Serial.read() - '0'; 

		if (val == 1) { 
		irsend.sendRaw(PowerOn,68,38);
		}
		else if (val == 0) 
		{
				 irsend.sendRaw(Source,68,38);
				 delay(500); 
		}
		else // if not one of above command, do nothing
		{
		}
 
}

Do anyone have any idea what to do?

I have tried 3 example programs to try to get data back from the pro micro over the serial with VB

nada

I can send data fine Here is the code I tried

VB side

Public Class Form1
Dim WithEvents SerialPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConnectSerial()
End Sub

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
If SerialPort.IsOpen Then
SerialPort.Write(txtSend.Text)
Else
ConnectSerial()
SerialPort.Write(txtSend.Text)
End If
End Sub
Private Sub ConnectSerial()
Try
SerialPort.BaudRate = 9600
SerialPort.PortName = "COM7" 'notice how the ports are named? they HAVE to have COM in front of the number
SerialPort.Open()
Catch
SerialPort.Close()
End Try
End Sub

Delegate Sub myMethodDelegate(ByVal

            ConnectSerial()
            SerialPort.Write(txtSend.Text)

The ConnectSerial() function opens the serial port, which resets the Arduino. Waiting for it to reset before talking to it is not just a good idea.

Does the SerialPort_DataReceived method ever get called?

The general approach in this demo of communicating with a PC using Python applies to all PC languages.

As you can see it waits for the Arduino to send a message before starting to send data to it.

...R