Hi there !
I am currently using a Servo PDI-6225MG-300 which can rotate up to 295° I send(through Wi fi) a value between 0 to 295 which is the value of the angle (value called val).
#include <Servo.h>
#include <SPI.h>
#include <RF24.h>
#include <RF24_config.h>
int msg[1];
int val = 0;
RF24 radio(5, 10);
const uint64_t pipe = 0xE9E9F0F0E1LL;
Servo myservo;
void setup() {
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
Serial.begin(9600);
myservo.attach(9);
}
void loop() {
if (radio.available()) {
bool done = false;
while (!done) {
done = radio.read(msg, 2);
val = msg[0];
val = map(val, 0, 295, 0, 180);
Serial.println(msg[0]);
myservo.write(val);
}
myservo.write(val);
}
}
But I have a big problem, I can’t really control it precisely. He is achieving the 295° rotation when the value reach 180 so I tried to “map” the value but it doesnt work.
Is it possible to control it percisely ?
Is it because of the Servo Library which can only control between 0 to 180° ?
What am I doing wrong ?
Ps: spec of the servo
Brand Name: JX Servo
Item Name: PDI-6225MG-300 Degree
Max Angle: 295°
Dead Band: 4μs
Maximum Pulse Width: 500-2500us (for control board)
Motor: Iron core
Voltage range: 4.8V-6.6V
Speed (4.8V): 0.25 sec / 60 degree
Speed (6V): 0.21 sec / 60 degree
Torque (4.8V): 19.9 kg.cm
Torque (6V): 25.3 kg.cm
Size: 40.5 x 20.2 x 38mm
Weight: 62g
Cable: JR 265 mm
Bearing: 2BB
Output Teeth: 25T (Futaba Universal)
Thx in advance !
Seb