int servoPin = A3;
Servo myServo;
bool servoPositionUpdated = false;
int servoPosition = 0;
void setup() {
myServo.attach(servoPin);
Particle.function("pos", setPosition);
}
void loop() {
if (servoPositionUpdated == true){
myServo.write(servoPosition);
servoPositionUpdated = false;
}
}
int setPosition(String command){
int value = command.toInt();
if (value>180) {
return -1;
}
if (value<0){
return -1;
}
servoPosition = value;
servoPositionUpdated = true;
}
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. .