I have a few Servo motors I want to control I’m using pins:
D0, D1, D2, A3, WKP and RX.
I have not tested RX yet. But in Tinker D0, D1, D2, WKP all work without any issues and can control the motor movement. Setting these pins to analogWrite in Tinker gives me a slider from 0 to 255 and dragging the slider creates slight movements.
However setting A3 to analogWrite creates a slider from 0 to 4000+ and changing this value does nothing for the attached motor. Digital write works but analogWrite does not.
My code is super simple:
Servo myservo;
/* This function is called once at start up ----------------------------------*/
void setup()
{
//Setup the Tinker application here
myservo.attach(A3);
//Register all the Tinker functions
Particle.function("digitalread", tinkerDigitalRead);
Particle.function("digitalwrite", tinkerDigitalWrite);
Particle.function("analogread", tinkerAnalogRead);
Particle.function("analogwrite", tinkerAnalogWrite);
Particle.function("servo", servo);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
//This will run in a loop
}
int servo(String value)
{
myservo.write(value.toInt());
delay(100);
return 1;
}
What bugs me is the value range for A3 from 0 to 4k. Should I be setting a different mode or something on this pin?