Reading multiple chars, converting string to int (Serials)

Hey!
I'm trying to controll my stepper motor without using a library.
I want to control it via serial. I need three variables - direction (left, right), number of steps and speed.
OK.
Here's my problem - I would like to tell all this to arduino via serial. For example write in Serial Monitor: right, 100, 100 and watch my stepper moving.
It can also be: right [enter] 100 [enter] 100 [enter].
I have few problems here - how can I read multiple chars from serial? When i noramlly type '100', arduino treats it as 1, 0, 0. Second thing - even if I sucseed to read the data into an array, I still do not know how to use it later. I have no idea how to convert an array or string to integer, which i need :/.

Thank You for any help and please, forgive me all language mistakes, as I'm not an english speaker.

I'm trying to controll my stepper motor without using a library.

Why?

I want to control it via serial. I need three variables - direction (left, right), number of steps and speed.

Same inputs you'd need if you used the Stepper library.

Here's my problem - I would like to tell all this to arduino via serial. For example write in Serial Monitor: right, 100, 100 and watch my stepper moving.

Right is not a direction a stepper motor could understand. In case you haven't noticed, stepper motors rotate. Clockwise and counterclockwise are the only directions they understand.

I have few problems here - how can I read multiple chars from serial? When i noramlly type '100', arduino treats it as 1, 0, 0.

Yes. It is up to you to store them in an array until the end of packet marker (comma, enter, whatever) arrives, then deal with the string you have stored. If the string represents a single number, atoi() will convert it to an int for you.

Second thing - even if I sucseed to read the data into an array, I still do not know how to use it later. I have no idea how to convert an array or string to integer, which i need :/.

Well, now you do.

PaulS:
Right is not a direction a stepper motor could understand. In case you haven't noticed, stepper motors rotate. Clockwise and counterclockwise are the only directions they understand.

While I agree with you, there are a number of folks who use left and right, even for rotation. One phrase that comes to mind; "Lefty loosy, righty tighty..." It never made much sense to me, but it does to some.

Surely that's 'righty tighty'

dxw00d:
Surely that's 'righty tighty'

Yep.. R.. T.. there right next to each other on the keyboard! :slight_smile:

Why?

I'm learning the code. For the sake of practice.

Right is not a direction a stepper motor could understand. In case you haven't noticed, stepper motors rotate. Clockwise and counterclockwise are the only directions they understand.

Oh, thanks for info. As I said - I'm not perfect english-speaker, but I'm sure You understood what i meant by "left".

Yes. It is up to you to store them in an array until the end of packet marker (comma, enter, whatever) arrives, then deal with the string you have stored. If the string represents a single number, atoi() will convert it to an int for you.

Do i store them in array by Serial.readBytesUntil()?

Well, now you do.

Well, thank You for that.

Do i store them in array by Serial.readBytesUntil()?

Questions on how to handle Serial comms come up on a daily basis, often multiple times a day. Should be pretty easy to search out and read those threads. Most of them are on the very topic of reading in data and parsing it into ints, floats, strings, etc.

Questions on how to handle Serial comms come up on a daily basis,

So often, in fact, that someone (not mentioning any names) put together a blog on the topic: