Im just getting back into Arduino and was trying to hook up some servo motors but for some reason whenever I input the point i want it to go to, it just springs back to 0
Heres the code
#include <Servo.h>
Servo myservo; // create Servo object to control a servo
Servo servo2;
int numb = 10;
void setup() {
myservo.attach(11); // attaches the servo on pin 9 to the Servo object
servo2.attach(10);
Serial.begin(9600);
Serial.print("KILL KILL KILL");
}
void loop() {
while ( Serial.available() == 0){}
numb=Serial.parseInt();
Serial.println(numb);
servo2.write(-numb);
myservo.write(numb); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
Any help is appreciated. Thank you!
Assuming that you're using the serial monitor, what is the line ending set to? Try to set it as below

Reason is that after the parseInt() there might still be data (carriage return and line feed) that is parsed and will result in a zero value.
You can study Robin's updated serial input basics to get ideas how to read serial data and parse it.
You can verify for yourself that @sterretje 's explanation is correct with the following cut down example (leaving line ending set as you had it, which was likely CR+LF):
int numb = 10;
void setup() {
Serial.begin(9600);
}
void loop() {
while( Serial.available() == 0 ) {}
numb = Serial.parseInt();
Serial.println(numb);
}
parseInt would terminate with the CR and return the proper number, and next time through the loop your code would see the trailing LF and parseInt would return 0.
Here's a quick & dirty fix that allows you to still have any combination of CR & LF as your line ending:
#include <Servo.h>
Servo myservo; // create Servo object to control a servo
Servo servo2;
int numb = 10;
void setup() {
myservo.attach(11); // attaches the servo on pin 9 to the Servo object
servo2.attach(10);
Serial.begin(9600);
Serial.print("KILL KILL KILL");
}
void loop() {
while( Serial.available() == 0 ) {}
if( isdigit(Serial.peek()) ) {
numb = Serial.parseInt();
Serial.println(numb);
servo2.write(-numb);
myservo.write(numb); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
} else {
(void)Serial.read(); // toss non digit character
}
}
This worked perfectly! Thank you so much for the help.