Go Down

Topic: Writing to Arduino in a loop (Read 207 times) previous topic - next topic

nando88

I have a C# app that writes to an Arduino and makes it turn on a led in a loop, with it connected to my PC.
When I connect a mouse and the led is turned on and has to remain like that for a while, the Arduino turns it off and back on again, after I have connected the mouse.
Is this normal?
Would this mean that the Arduino gets disconnected from PC and back on again after I have connected the mouse?
I am not closing the port, so I don't know why this is happening.
Any help will be appreciated.
Thanks.

Robin2

#1
Sep 09, 2017, 09:24 pm Last Edit: Sep 09, 2017, 09:27 pm by Robin2
You need to explain yourself a lot more clearly.

What are you connecting the mouse to?
How does the mouse relate to the C# program?
What does the C# program do when the mouse is connected?

Post the Arduino program.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

nando88

I am using the serial port to make the connection to the Arduino.
I have a method that detects the changes in serial port, but from what I can tell, it doesn't have any relationship with the mouse or any other us peripherals connected to PC, since this happens when I connect any uab device to the PC, while the led is on.

nando88

I figured out what is wrong. It is a race condition. The thing is that I don't know how to fix this problem.
Can you please help me?

sterretje

#4
Sep 10, 2017, 07:52 am Last Edit: Sep 10, 2017, 07:52 am by sterretje
Race condition where? In the Arduino or in your C# application.

If it's the Arduino, post a question (including Arduino code) in Programming questions.

If it's the C# application, you can post your C# code in this thread and hope that somebody can help or find a dedicated C# forum and post the question and code there.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Robin2

I figured out what is wrong. It is a race condition. The thing is that I don't know how to fix this problem.
Can you please help me?
The questions I asked in Reply #1 are still relevant and have not been answered.

Plus the questions in Reply #4

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up