storing on a  integer variable from serial read.

inData[index] = '\0';

'\0';

what it does exactly?

inData[index] = '\0'; sets the array position defined by index to NULL.

rpm100, rpm10, and rpm1 should be integers.

When you send serial data, the process is not very fast. The Arduino is.

It might execute the loop function several million times while you are pecking out A200 on the keyboard and clicking the send button.

As soon as the A arrives on the serial port, it is read, determined to be an A, and the next three bytes (which haven't arrived yet) are read. The function returns a -1 because the data has not arrived yet.

You need to wait for the data to arrive before trying to read it.

ok one more

this one

int inInt = atoi(inData);

takes the hole Indata from Indata[1] to indata [10]

and makes it one number


isnt the same to write

inData[index] = '\0';

and why the / and the two ' '

i mean my rpm output is inInt "1 to 3 of the Indata"?

or

100*Inint[1]+10Inint[2]+Inint[3]

where is my mistake

Your mistake is that you are reading four characters, when you don't know that there are four characters to read, proved by

[ch913]220 gives -49-49-49-5439
A000 gives -49-49-49-5439

You must make sure that "Serial.available" returns at least 1 before reading a character.

this one

int inInt = atoi(inData);

takes the hole Indata from Indata[1] to indata [10]

It looks for the first NULL value in inData[0] through inData[9]. That terminates the processing. The characters up to that NULL value are interpreted as in integer.

inData[index] = '\0';

and why the / and the two ' '

Some things just are, OK. That is way to stuff a NULL into an array.

inData[index] = '\0';

If you just wrote this as "inData[index] = '0';", then "inData[index]" would contain the value 48(decimal), or 0x30), in other words, the ASCII character for zero.

It's an odd convention, but '\0' gives you the actual value zero (0 decimal, zero octal, 0x00).
It could be written simply "inData[index] = 0;" - never quite understood why it isn't, other than to draw attention to the fact that it is terminating character value.

it just not want to work for me

That's a shame. It works for everybody else.

Post the code you have now.

its working with the servo
but not with the stepper motor

the stepper motor code is already tested

I have to change a value only

position = map(time,56000,38000,40,0); //pulse meter

position = map(rpm,127,255,40,0); // rpm meter

i will find it

i finaly made it

i think that the problem was not only my code

but not on pins 12,11,10,9 that i have it from the begging

i will test the pins tomorow

now i am not going to post the code yet because i have also two servos and i want to use them as fuel and temp meter


now which is the best way to send two more numbers

copy paste the code with different start and end symbols

or send one number and then try to extract the 3 different numbers with div and mod?

thanks a lot for your help

If the numbers are sent together, you could do <A12,B65,C87>. If there are sent seperately, you could sent .

i could do

AXXXBCXXXDEXXXF

and the coppy paste your code 3 times

each time i will ha a different start end command

i think

you read serial data in series

but you need delays between the inputs

an example from the code that the arduino uses in the video

 [quote]
    kind_of_data = [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]read[/color]();
    [color=#CC6600]if[/color] (kind_of_data == [color=#006699]'R'[/color] ) Read_Rpm();


//lines of code
//lines of code

[color=#CC6600]void[/color]  Read_Rpm(){

  [color=#CC6600]delay[/color](2);
  [color=#CC6600]int[/color] Rpm100 = [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]read[/color]()- [color=#006699]'0'[/color];
  [color=#CC6600]delay[/color](2);
  [color=#CC6600]int[/color] Rpm10 = [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]read[/color]()- [color=#006699]'0'[/color];
  [color=#CC6600]delay[/color](2);
  [color=#CC6600]int[/color] Rpm1 = [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]read[/color]()- [color=#006699]'0'[/color];

  [color=#CC6600]int[/color] rpm = 100*Rpm100 + 10*Rpm10 + Rpm1;

[/quote]

if you increase the baund rate to 115200 then the delay could be 1 ms

maybe less but i didnt test it