Displaying serial.print's from arduino to MATLAB GUI

I would like to display the data readings from the ultrasonic sensor to a MATLAB GUI. any thoughts on how would i approach this? below is my code for the arduino

const int trig = 6;
const int echo = 7;
long time, dist;


void setup()
{
  // put your setup code here, to run once:
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
}

void loop()
{

  digitalWrite(trig,LOW);
  delayMicroseconds(2);
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);

  time = pulseIn(echo, HIGH);
  dist = (time/2) / 29.1;
  
  Serial.print(dist);
  Serial.println(" cm");
  
  delay(500); 

}[code]

I would like to display the data readings from the ultrasonic sensor to an edit text in MATLAB GUI. any thoughts on how would i approach this? below is my codes on the arduino part

THESIS_Experiment.ino (1.04 KB)

I would like to display the data readings from the ultrasonic sensor to an edit text in MATLAB GUI. any thoughts on how i should approach this? below is the code on my arduino.

THESIS_Experiment.ino (1.04 KB)

This issue has been commented about before, In this Forum... Why not search for the answer first... When I try to answer a post like this, First I search for an answer that fits the question... It's really easier... In the long run.. If you cannot find your solution by a 'diligent' search, Then it's time to ask for help.. Finally read the second sticky note.. And the Third Too.. The One about how to post in this forum, It's not long and your success will be Much Better.. Hint... ( it's the second and third down from the top )...

Doc

pdca16: I would like to display the data readings from the ultrasonic sensor to an edit text in MATLAB GUI. any thoughts on how i should approach this? below is the code on my arduino.

Get your data displaying in the arduino serial monitor first, then work on the matlab part.

zoomkat: Get your data displaying in the arduino serial monitor first, then work on the matlab part.

i've already done that. my problem now is displaying it on MATLAB GUI

When you ask for help, you need to make it easy for others to help you. You should post your code using code tags.

See item 7 in how to use this forum.

The way you have added your code means that anyone trying to help you will have to:

  • download your code.

  • save it in a folder with the correct name.

  • open the Arduino IDE.

  • read the code.

  • delete the code when finished.

I don't want to go through that procedure, I want to be able to read it on this page.

So far your post has had 22 views, but only 1 person has downloaded your code.

Sorry, here is the arduino code:

const int trig = 6;
const int echo = 7;
long time, dist;

void setup()
{
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  pinMode(13,OUTPUT);

}

void loop()
{
  
  digitalWrite(trig,LOW);
  delayMicroseconds(2);
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);

  
  time = pulseIn(echo, HIGH);
  dist = (time/2) / 29.1;
  
  Serial.print(dist);
  Serial.println(" cm");

  delay(500);


}
[code]

to a MATLAB GUI.

That seems like strictly a Matlab issue, but I really don't think that Matlab needs to be told that each distance value is in centimeters.

Don't DOUBLE POST.

...R

PaulS: That seems like strictly a Matlab issue, but I really don't think that Matlab needs to be told that each distance value is in centimeters.

I need to know the MATLAB codes on the GUI part on how i would display the serial data in the edit text.

pdca16: Sorry, here is the arduino code:

void setup()
{
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  pinMode(13,OUTPUT);

}

Where did you Initialize the Serial hardware? Serial.begin(9600); ?

Chuck.

I need to know the MATLAB codes on the GUI part on how i would display the serial data in the edit text.

Check the URL you are using. This is NOT matlab.anything.