Created
March 1, 2023 09:11
-
-
Save mfkenson/4784b45dedc86f5ffc9f273e684d6e39 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; | |
void setup() { | |
Serial.begin(9600); | |
myservo.attach(7); | |
myservo.writeMicroseconds(1500); | |
} | |
void loop() { | |
while (Serial.available() > 0) { | |
int microsec = Serial.parseInt(); | |
if (Serial.read() == '\n') { | |
microsec = constrain(microsec, 1000, 2000); | |
myservo.writeMicroseconds(microsec); | |
Serial.println(microsec); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment