int servoPin = A3;
Servo myServo;
int servoPos = 0;
void setup() {
myServo.attach( A3 );
pinMode(servoPin, OUTPUT);
Particle.function("servo", servoControl);
Particle.variable( "servoPos" , &servoPos , INT );
}
void loop() {
}
int servoControl(String command)
{
int newPos = command.toInt();
servoPos = constrain( newPos, 0 , 180);
myServo.write( servoPos );
return 1;
}
Click to Expand