I am trying to read data using an app designed by C# or VC++ /CLR / 2010, unfortunately no success. I know there is a lot of examples out there but non of them is working for me. It seems to be that the problem is when i use readline( ) It times out. I am posting my code and my arduino code hoe someone can help!
Arduino code :
int SensorPin = A0; // A0 is the sensor input
int SensorValue = 0;
float outputValue = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//analogReference(INTERNAL); //Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
// Read Values fro sensor
SensorValue = analogRead(SensorPin);
// map it to the range of the analog out:
outputValue = map(SensorValue, 0, 1023, 0, 5000);outputValue=outputValue/1000;
}
Note :-- timer interval is 10 msec.
Also I read about the DATArecive handelr but I am not sure how to use it , if someone out there can explain it will be great
First, please read Nick Gammon's post at the top of this Forum on the proper way to post source code here using code tags.
Next, I believe that your C# code will open a port but, seeing the Arduino COM port busy, will select a different COM port. Likewise, I see nothing in the Arduino code to check and see if something has come into the Serial object (e.g., Serial.available()). Use the control panel to find out if they are the same. If not, you need to work out a way to share the same COM port, or a least read/write from the known COM ports. Take a look at Robin2's discussion of Serial port usage.
econjack sorry I am new to the forums , I make sure to do it correct next time.
I think you are right it opens the port and I see the light on the Arduino turn on when I sen open port command.
But I am not sure how using Serial.available() will help in this case ?
I also don;t think there is a way to share the com port with both of them ? Why would I need to share the ports tho ?