Interfacing Arduino Due Serial data with PC application

Dear All,
I am new to programing on embedded platform. Currently I am trying to interface my arduino board with ultrasound sensor and read serial data, which is working fine on the Arduino IDE. I need to read this data from my VC++ environment and display on image.
How do I read the serial data using cpp code ?
What is the library to read from USB ?
How do I compile both the code simultaneously ( code in VC++ environment and the sensor based code) ?

Request help

Regards,

It simple can you post your code here. of ultra sound.

I can give code which i develop for other . But you should have knowledege of create a button; assigning proper tag for them. etc.

if you send code let me try to what alternation need to be done. Or if you do own alternation well n good

How do I read the serial data using cpp code ?

The same way as from the Serial monitor, if that is what you are currently using to communicate via Serial. It is convenient to use separate Serial ports for communication with external devices and debugging/information messages.

How do I compile both the code simultaneously ( code in VC++ environment and the sensor based code) ?

I don't understand the question. VC++ runs on the PC and the "sensor based code" runs on the Arduino and they are compiled separately.

This demo shows how to communicate with an Arduino using Python on a PC. The general principles will be the same in all PC languages. It may be useful for your learning process to write a VC++ program that takes the place of my Python program to communicate with my unchanged Arduino program. That way you can be sure the Arduino side of things works while you experiment with VC++.

...R

Thanks for your help ..
// First Sensor
int trigPin = 12; //Trig - green Jumper
int echoPin = 11; //Echo - yellow Jumper

long duration, cm,m, inches;

void setup() {
//Serial Port begin
Serial.begin (9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop()
{

// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
// convert the time into a distance
cm = (duration/2) / 29.1;
inches = (duration/2) / 74;
m = (duration/2) / (29.1*100);
Serial.print(m);
Serial.print("m, ");
Serial.println();
delay(250);
}


Above is the code that use for the ultrasound sensor. The code works fine with the Arduino IDE. I can serially receive data from the USB port.
My next task was to write a C code ( for which I currently use the VC++ environment) to read the distance data received from the arduino board and save it in a file and use it further for some decision making.

How do i access the arduino libraries from VC++ environment.?

Meanwhile Robin, i am going through the Python and arduino interface and trying to understand how could i use it under my existing VC++ environment.
Thanks once again for all ur support

Regards,

probook:
How do i access the arduino libraries from VC++ environment.?

I imagine that VC++ does not need access to any Arduino specific stuff. It just need access to the COM port the Arduino is connected to.

By the way my Python program should work on Windows if you edit the reference to the serial port.

...R