I am going to do some arduino project with servo. So now i am testing this servo. Servo is connected to 5v to arduino and arduino is connected to computer USB.
#include <Servo.h>
Servo servo1;
int input = 0;
void setup()
{
servo1.attach(7);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0)
{
input = Serial.parseInt();
servo1.write(input);
Serial.println(input);
delay (1000);
}
}
Problem is that when i write to serial monitor 50, it turns to 50 and then back to 0, but the code doesnt say anything about turning back. If i write for example 120 servo is crazy xD turning right and left.
And this is also interesting when i tried this at school it worked fine, also it works on Tinkercad. So i think that problem isnt in code or circuit but in power supply but which exactly? 
EDIT: In serial monitor: When i write for example 50 it write 50 and then 0, why is here zero?
Madshot:
EDIT: In serial monitor: When i write for example 50 it write 50 and then 0, why is here zero?
because when you send your data (i.e. 50) you may be sending a New Line and a carriage return.
turn that off in the Serial Monitor... select just NewLine

BulldogLowell:
because when you send your data (i.e. 50) you may be sending a New Line and a carriage return.
turn that off in the Serial Monitor... select just NewLine
I have selected Newline. IDK why is this happening that it turn back or start going crazy. I think it is powering from computer usb, it works fine in school and in home pc no. But i am going to buy some external power supply for more and bigger servos so maybe i will solve this problem with it.
Madshot:
I have selected Newline. IDK why is this happening that it turn back or start going crazy. I think it is powering from computer usb, it works fine in school and in home pc no. But i am going to buy some external power supply for more and bigger servos so maybe i will solve this problem with it.
what happens on the Serial Monitor when you enter a value (i.e. 50, like you mention)?
Sorry for not replying, i solved this and i didnt write here. Problem was that i have selected the Newline, thats why in the monitor was 0 after my entered number and servo went back to 0. But i changed it to No line ending and now it is good. I also read something about these options so now i know :-). Also thank you Bulldog i didnt know about these options and didnt know what they do.