Go Down

Topic: how to interpret the serial data (Read 3023 times) previous topic - next topic

AWOL

The problem looks to be that you're never printing the value of "inData" when it has some dta a in it.
Move the final "print" inside the "started && ended" condition, but before you reset the string.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

AWOL

#16
Mar 14, 2013, 05:35 pm Last Edit: Mar 14, 2013, 05:37 pm by AWOL Reason: 1
The problem?
You didn't open the serial monitor, you didn't select the correct line speed, you didn't compile the code, you didn't upload the code, you didn't hit "send"...
It works, perfectly.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

latee

im sory....it works it print but the problem is it auto scroll...

AWOL

You'll have to explain what that means, and why you perceive it to be a problem.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

latee

THANK YOU very much...is it functional of what i want to do as what i said in my first post?

latee

is it functional if the computer will send two type of  data for example <jvvmv>{fff},is it posible to use two start and end maker...

PaulS

Quote
is it posible to use two start and end maker...

Yes, but...

<jvvmv,fff> is easier to deal with. Save all the data, then use strtok() to parse into jvvmv and fff.

With two start and end markers, you need two arrays, and you need to keep track of which array to store a character in. Does f go in the first buffer or the second buffer?

AWOL

Quote
what i need to do?
you need to start thinking for longer than 20 minutes at a time, and working through some of the examples in the IDE.
I believe I've said this before, but it's worth repeating.

(Hint: you haven't written anything called "sendCommand" yet.)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

latee


mixania

This example may help you grasp the basics.

Code for Arduino:

Code: [Select]
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(A0));
  delay(2);
}


Code for Processing:
Code: [Select]
import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph

void setup () {
// set the window size:
size(400, 300);       

// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my  Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}
}

Arduino Uno R3
Mac OSX Lion

Go Up