Go Down

Topic: serial comunication (Read 715 times) previous topic - next topic

alva

Hi guys,...
Would u help me?
I looking for a way to make my arduino-uno can received many variables from PC. 8)

Exactly I have a project that requires sending data (variables) from Delphi output to arduino, and process it on arduino. :smiley-roll-sweat:
probably 10 variables.

Please help me.......

AWOL

And how are these variables formatted?
"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.

alva

it's all  parameters..
example

VS 2000
its mean VS(Viscosity standard) have a value 2000 ]:D

Arrch

What do you have so far?

alva

i'm sorry... So far i try to use gobetwino, but i confused with the syntax. and its really complicated for me :smiley-roll-sweat:

AWOL

Have you worked through any of the supplied examples?
"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.

HazardsMind

#6
Nov 13, 2012, 06:35 pm Last Edit: Nov 13, 2012, 06:40 pm by AWOL Reason: 1
Arduino does not have a split function like Processing does, SO, you need to make your own split function.
Here is something I made to help me. this will take in 3 values and change them to ints.
Code: [Select]

#include<string.h>
int X,Y,State,currentCommand=0;
String x,y,state;


// LED connected to pin 13 (on-board LED)
byte ledpin = 13;

void setup()
{
 pinMode(ledpin, OUTPUT);
 Serial.begin(9600);       // start serial communication at 9600bps
}

void loop() {
 if( Serial.available())       // if data is available to read
 {
   digitalWrite(ledpin, HIGH); //if data is being entered
   char val= Serial.read();
   if (val == ','){
     currentCommand++;
   }
   else {
     switch (currentCommand) { //add more case statements for more data
     case 0:
       x += val; //stores as a string
       val = ' '; //clear for new char
       break;
     case 1:    
       y += val; //stores as a string
       val = ' ';
       break;
     case 2:    //gets the last data
       state += val; //stores as a string
       val = ' ';
       currentCommand = 0; // this only allows one char to be saved here, modify to save more.
       X=x.toInt();               //delete .toInt() if needed
       Y=y.toInt();               //delete .toInt() if needed
       State = state.toInt(); //delete .toInt() if needed
       //shows what you entered
       Serial.print(X);
       Serial.print(", ");
       Serial.print(Y);
       Serial.print(", ");
       Serial.println(State);
       
       x="";y="";state=""; //clear values
       X=0;Y=0;State=0; //clear values
       break;
     }
   }  
 }
 digitalWrite(ledpin, LOW);
}


Hope this is able to get you started.

Moderator edit: CODE TAGS dammit.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

alva

Yes... But
it doesnt work correctly. And i can't trace the error because i confused with the sintax.
maybe someone can help me with the other ways?

AWOL

Quote
i can't trace the error

First mention of an error.
Care to expand?
"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.

alva

thanks a lot HazardsMind ^_^ ^_^....
It really helps me:)

danb35


Yes... But it doesnt work correctly. And i can't trace the error because i confused with the sintax.
maybe someone can help me with the other ways?

Maybe you can tell us (1) what you're doing already (i.e., show us your code), (2) what you expect it to do, (3) what it's actually doing, and (4) what errors you're getting?

Go Up