Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- // a maximum of eight servo objects can be created
- int pos = 0; // variable to store the servo position
- void setup()
- {
- myservo.attach(9); // attaches the servo on pin 9 to the servo object
- Serial.begin(9600);
- while (! Serial);
- Serial.println("Enter desired servo position");
- }
- void loop()
- {
- String content = "";
- char character;
- while (Serial.available())
- {
- character = Serial.read();
- delay(5);
- content.concat(character);
- }
- if (content != "")
- {
- int spos = atoi(content);
- myservo.write(spos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement