Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cf03b78

Browse files
authoredJan 9, 2018
Merge pull request #194 from VVESTM/fs90r
Add fs90r example to servo library
2 parents bd21114 + 8b165cc commit cf03b78

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
 
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Use servo library to control a FS90R motor
3+
4+
Motor information :
5+
http://www.feetechrc.com/product/analog-servo/micro-1-3kg-cm-360-degree-continuous-rotation-servo-fs90r/
6+
Must respect the pulse range in order not to damage servo.
7+
8+
*/
9+
10+
#include <Servo.h>
11+
12+
Servo fs90r; // create servo object to control a servo
13+
14+
int potpin = 0; // analog pin used to connect the potentiometer
15+
int val; // variable to read the value from the analog pin
16+
int servopin = 9; // pin used to connect the servo
17+
18+
void setup() {
19+
Serial.begin(115200);
20+
21+
fs90r.attach(servopin, 900, 2100); // attaches the servo on pin 9 to the servo object
22+
// Be carefull to min and max values...
23+
}
24+
25+
void loop() {
26+
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
27+
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180, at 90,
28+
// motor is stopped)
29+
30+
Serial.print("val = ");
31+
Serial.println(val);
32+
33+
fs90r.write(val); // sets the servo speed according to the scaled value
34+
delay(15);
35+
}
36+

0 commit comments

Comments
 (0)
Please sign in to comment.