CONTROLLING SERVO VIA SERIAL MONITOR

servo serial

/* We can control this servo through
the serial monitor,
type the angle value that we want (0-180)
then press enter.

the code can be downloaded at :

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/Servo_serial.zip

*/

#include <Servo.h>

Servo servo1;
long num;

void setup()
{
servo1.attach(9);
Serial.begin(9600);
Serial.print(“Enter Position = “);
}

void loop()
{
while(Serial.available()>0)
{
num= Serial.parseInt();
Serial.print(num);
Serial.println(” degree”);
Serial.print(“Enter Position = “);
}
servo1.write(num);
delay(15);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s