Hi gyus,I have a little problem with my code.I found out that when you send somethng to "Serial.read () ;" it receives number's position in ASCII table.For example if i send 1 it receives 49.Do you now I can make it to receive the number I send, not its ASCII position?Here is my code:

It is a bad idea to use incomingByte in the way you did, because it gets used whether it has been updated or not. Seems like everything should be within the if-statement.

I'm not sure i uderstand you write,but i need it to be that way because i need to spin the motor without stopping,+ that when incomingbyte is 0 the esc is in neutral possition.But thx for the anser i will have it in mind next time.

I'm not sure i uderstand you write,but i need it to be that way because i need to spin the motor without stopping,+ that when incomingbyte is 0 the esc is in neutral possition.But thx for the anser i will have it in mind next time.

for (myAngle = 170; myAngle <= 170; myAngle++) it the motor spins without stopping.The speed is controled by changing the numbers from 70 to 170.The only problem i have is that i cant make the serial function to reseave what i send not the ASCII table. I am not sure you understand me

For example if i send 1 it receives 49.Do you know how I can make it to receive the number I send, not its ASCII position?

I think one main problem is your idea about ascii / binary and serial transmission.

If you use Serial Monitor , enter a "1" and press Send, the text being sent to Arduino consists of that character '1' which shows up as a decimal number 49. Similarly, cou could send an 'A' and would receive a 65.

You might have different code on the sending side, directly sending a single byte with a value of 0 to 100, but that's not Serial Monitor.Rather make it to interpret the characters you send: "100" are 3 ascii characters, plus hopefully a newline character that indicates the end of the number.

See Nick Gammon's hints on dealing with Serial input ( He prefers visible markers to indicate start and end of numbers like "<100>" )

Quote

Oh I think I understand you this time.You mean that it has to be someting like this :if (incomingByte!=0)

You're on the way. Unfortunately, incomingByte is not 0 any more after you received anything. You might set it to 0 whenever your loop restarts, or in an else { } banch of if( Serial.available() )

The only problem i have is that i cant make the serial function to reseave what i send not the ASCII table.

You have a couple options. Since you're not sure exactly how many digits the user is going to send, the most common is to use a start and/or stop byte. Everything between is processed as part of the number. Simple example:

What this does is stores every character received into a char array. When it received the newline character it null terminates the array (making it a string) and calls the atoi function which converts a string to an int. You then do what you want with the int and reset the index. The important thing to note is that you need to send a newline after you're done inputting the number. If using the Arduino serial monitor, change the appropriate drop down in the bottom right.

Hey again guys I hope i am not too cheeky,but can u help a little bit more i am not sure what i do wrong.

Too many/too little curly braces. This is where proper formatting helps a great deal. Do yourself a favor and use the auto format tool in the Arduino IDE (Tools > Auto Format) and it should be more apparent.