int servoPin = A3;
int weatherCondition = 0;
Servo myServo;
void setup() {
// attaches the servo on the A3 pin to the servo object
myServo.attach( A3 );
//Register our Particle to control the servo
Particle.function("weather", weatherControl);
// Keep a cloud variable for the current position
Particle.variable( "weatherCondition" , &weatherCondition , INT );
}
void loop() {
}
int weatherControl(String command)
{
// Convert
int newPosition = command.toInt();
// Make sure it is in the right range And set the position
weatherCondition = constrain( newPosition, 0 , 180);
// Set the servo
myServo.write( weatherCondition );
// done
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. .