Running servo through serial monitor

I am totally new to this coding stuff, so i was hoping you guys would help me? :slight_smile:
I want to change the angle of my servo through serial monitor, but no matter what i type it keeps resetting to 10 for some reason.

Well… this is how far i got:

#include <Servo.h>
Servo servoen;
int lol = 0;
void setup()
Serial.begin (9600);
void loop()
if (Serial.available() > 0)
lol =;


10 is the ASCII code for new line.
Change the line ending control on the serial monitor to "none".
Better still, find out how to parse a multi digit number, so you don't have to translate positions to ASCII codes.

Please get into the habit of using code tags when posting code.

Thanx :slight_smile: that fixed the "10" problem!

Do you have any examples on how to parse multi digit numbers into the thing? I have been looking into it, but didnt get very far :confused:

...aaaand i dont know what code tags is :S

Have a look at Serial Input Basics - simple reliable ways to receive data.


Damn. i wish i understood this… but i kind of dont. in the tutorial, i sort of understood that char converts ascii to normal numbers, but it only goes up to 137? is that right? cause i need 180 for this one. Is it array or string i need to look into?

I don’t know where 137 comes from, but once you’ve subtracted the ASCII value for the character ‘0’ from each digit, the rest is simply decimal arithmetic.

137 == (1001) + (103) + (1*7)

oh my..... i shouldnt be doing this. I dont understand anything. thanx a lot for trying to help me, but i think im way too lost on this project :frowning:

replace with Serial.parseInt() as the forum(And Robin2) suggested me.

What?? :open_mouth: that did it! :smiley: thank you so much! (and robin ofc :))

replace with Serial.parseInt() as the forum(And Robin2) suggested me.

Just to be perefctly clear I have NOT recommended the use of Serial.parseInt(). The whole point of the examples in Serial Input Basics is that they are non-blocking.


lol. i dont even care xD it works now <3

lol. i dont even care xD it works now <3

I think I have figured out lol

But what do xD and <3 mean.

And it does not seem to be a very kind response to my attempt at helping.