int servoPin = A2;
Servo myServo;
int servoPos = 0;
void setup() {
// attaches the servo on the A3 pin to the servo object
myServo.attach( A2 );
//Register our Particle to control the servo
Particle.function("servo", servoControl);
// Keep a cloud variable for the current position
Particle.variable( "servoPos" , &servoPos , INT );
}
int servoControl(String command)
{
int newPos = command.toInt();
servoPos = constrain( newPos, 0 , 170);
myServo.write( servoPos );
return 1;
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .