Pages: 1 [2]   Go Down
Author Topic: how to interpret the serial data  (Read 2616 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 14, 2013, 11:37:37 am by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll have to explain what that means, and why you perceive it to be a problem.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got it...thank you very much
Logged

New York, NY
Offline Offline
Full Member
***
Karma: 2
Posts: 142
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This example may help you grasp the basics.

Code for Arduino:

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

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

Code for Processing:
Code:
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++;
 }
 }
 }
Logged

Arduino Uno R3
Teensy 3.0
Mac OSX Yosemite

Pages: 1 [2]   Go Up
Jump to: