Go Down

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

latee

Mar 14, 2013, 09:44 am Last Edit: Mar 14, 2013, 10:10 am by nehj Reason: 1
can u please give me a sample that are receiving a serial data,that f the mcu receive a charater 'a' the corresponding data will store in a buffer and when the character 'b' is detected d corresponding character will store to other buffer..can u please give me a related sample

AWOL

Code: [Select]
if (Serial.available ()) {
  int inChar = Serial.read ();
  switch (inChar) {
    case 'a': // do something
    break;
    case 'b': // do something else
    break;
   default: // do something completely else
  }
}
"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

The code I gave you is just an incomplete example - you need to fill in the blanks, or you could rewrite as, say, a simple state machine.
You original question wasn't specific.
"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

ah...i know that it is incomplete i just want to know if it is applicable to what i want to do?tnx

PaulS

Quote
the char 0999999999 will be save to a buffer

Which ONE key did you press to type the character 0999999999?

latee

one key??i want to store it in a buffer...this character will be send by the computer to the arduino,if ahm..for example the original data is a099999bTYYYYU, IF character 'a' is detected the 099999 will be store to a buffer and if character 'b' is detected the TYYYYU will be store to another buffer....please help me to do this...

PaulS

Proper use of capital letters and punctuation would really be appreciated here. You sound like a little boy whining.

You keep saying you want to store A character, and then you say that the character is 0999999999.

Well, I have news for you. 0999999999 is not a character. It is a string.

If you want to ask about how to read characters, and store them in an array AS A string, then say that. Don't keep referring to 0999999999 as a character.

latee

i'm so sorry for that....im unfamiliar with this,,,
ahm..is it possible to use the switch case function??plz help me

AWOL

I've shown you how to wait for and read one character into one particular buffer called "inChar", and make a decision based on the value of that character.
It isn't a great leap of imagination to read in further characters and read them into other buffers.
"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

Some application, a little effort, and maybe work through some of the examples supplied in the IDE.
"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

plz...give me a specfic examples

AWOL

It's been a while since I looked at the IDE supplied examples, but I'm pretty sure there's (at least) one on serial comms, and another on arrays.
I'd start with those.
"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

please give me the very specific examples in IDE pls???

AWOL

I'm posting from my tablet, so I'm afraid I can't.
What did you do to help yourself in the fifteen minutes between my last post and yours?
"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.

Go Up