Created
October 24, 2018 16:33
-
-
Save cheewee2000/7d5e9f83a1d7d61ae176d028b363db6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo myservo; // create servo object to control a servo | |
int servoPos; | |
void setup() { | |
//start serial communication at 9600baud (pulses per second) | |
Serial.begin(9600); | |
myservo.attach(9); // attaches the servo on pin 9 to the servo object | |
} | |
void loop() { | |
//check if there's anything in Serial RX | |
if (Serial.available() > 0) { | |
servoPos = Serial.readStringUntil("\n").toInt(); | |
myservo.write(servoPos);// tell servo to go to position 0-180 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment