I am assuming that you already have a simple knowledge of the .NET and Arduino (software & hardware) platforms. If not, there are many tutorials on the internet to help get you started. Let's begin by putting the program on the Arduino.
void setup() {
Serial.begin(9600);
}
//Sends the Number 1234 Over the Serial Port Once Every Second
void loop() {
Serial.write(1234)
delay(1000)
Module
Module1
Sub
Main()
Dim
userRespond
fetchedData
writeString
Console.WriteLine(
"Type R to Read Serial Port."
)
userRespond = Console.ReadLine
If
userRespond =
"R"
Or
"r"
Then
port
As
New
System.IO.Ports.SerialPort
port.PortName =
"COM4"
port.Open()
port.BaudRate = 9600
fetchedData = port.ReadByte
Console.WriteLine(fetchedData)
Console.ReadLine()
Else
"Not a Recognized Command."
End
forgot semicolon on two lines in Arduino Program in Loop section:
Serial.write(1234);
delay(1000);
Also unused variable in.NET
Dim writeString
Also running the program VB.NET 2012 Professional, on Windows 8; when pressing either "R" or "r" the Arduino returns 210 in the console window.
And changing it to be a string of Serial.write("1234") it returns 49 in the console window. not sure if this is HX or what's going on?