Phrasing a Command

Howdy

I have been all over Arduino Language Reference trying to figure out how to receive a command over the USB serial port. Once it’s received I will use the case or ifelse function to decode the command.

I need help in doing this. What I read so far is way over my head an confusing. Can some one help me what seems to be a simple thing. I am newbe to programing , so please excuse my newbe questions. :oops:

Have a great day.

Rocket Nut

https://www.arduino.cc/en/Tutorial/SwitchCase2

That’s a great example darrellg. A big thanks. :smiley:

Here is an example of a couple possible command:

File Name >Flight 25

Start Logging > 100

How would I get this string into the sketch? Like you did with the switch is how I would do the decoding of the command. Possible looking like:

// Separate command string from data string

commandstring = ??? // Command extraction code

datastring = ??? // Data string extraction code

// Decode commandstring

switch (commandstring) {

case ‘File Name’:

logfile = SD.open(datastring, FILE_WRITE);

case ‘Start Logger’:

LoggerSampleRate = int(datastring);

LogData(LoggerSampleRate);

default:

Serial.println(“Bad Command”);

}

I just need help in the extraction of the command and data strings. I know I can use an array, its the reading of string is where I am stumped.

Rocket Nut

https://www.youtube.com/watch?v=X5u2qCzcPn8

MonsterBot That’s exactly what I was looking for. Thanks :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

Rocket Nut

http://m.memegen.com/pq4w8j.jpg