Good day everyone,
I'm very new to this Arduino programming. But I already have a problem and cannot find an answer.
I hope someone can help.
I am using the Arduino Nano and have connected a temperatur sensor to it. When I open the Arduino Desktop App i can see that Data is being send through the "Serial Monitor".
I have now programmed a little programm with visual studio to read the data and have it shown on the screen.
But he never recieves any data. The problem is not the code ( I have checked with a friend, where it works ).
Maybe I have to activate something on my PC? Maybe Enable something? We are pretty helpless as to where the problem is.
No, what I meant was that it works on his PC. But unfortunately not on mine.
What I did was, he send me his working exe. Started it on my PC but while it works on his
it doesnt work on mine.
Dirichlet92:
No, the COM Port is not hard coded.
In the program it is on COM 4 and in the Arduino Desktop App Programm it is also on COM 4 and it works
Do you have aerial monitor open while testing the exe? You are aware that only one application can use the serial port at a time.
This is the Visual Studio Code, where it gets interesting. I hope it helps
//Read Button
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
// check if port is ready for reading
if (this->serialPort1->IsOpen) {
// Reset the text in the result label.
this->textBox1->Text = String::Empty;
// this will read manually
try {
this->textBox1->Text = this->serialPort1->ReadLine();
}
catch (TimeoutException^) {
this->textBox1->Text = "Timeout Exception";
}
// Disable the init button
// the asynchronous operation is done.
this->button1->Enabled = false;
}
else
// give error warning
this->textBox1->Text = "Port Not Opened";
That snippet of code is what reads from the port, if it is open, in response to a button click.
I can not imagine why reading incoming serial data is dependent on the user having to click a button. I really can not imagine why the author couldn't be bothered to give the button a meaningful name. There isn't a hope in hell of understanding what button 4 is supposed to do.
As it is written above, it is the "read button".
This simple piece of code was for me to get a signal from the Arduino if I press the "read"/"button4".
And once the button is clicked the value given from the Arduino is supposed to appear in the text box.