Back to Parent

int servoPin = A3;
int servoPosition;
Servo servo;
int countDown;
// bool flag = true;
void setup()
{
  Serial.begin( 9600 );
  countDown = Particle.function( "Set time to remind (unit: seconds):", setTime );
  servo.attach( servoPin );
}

void loop() {
    

  delay( countDown * 1000);

  
  for (servoPosition = 0; servoPosition <= 180; servoPosition+=1) {
      servo.write(servoPosition);
      delay(5);
  }
    for (servoPosition = 0; servoPosition <= 180; servoPosition+=1) {
      servo.write(servoPosition);
      delay(5);
  }
  
//   for (servoPosition = 180; servoPosition >= 0; servoPosition-=1) {
//       servo.write(servoPosition);
//       delay(5);
//   }
      
  //pinMode( servoPin, OUTPUT );
  //pinMode( servoPin, INPUT );
}


int setTime( String command ){
  Serial.println( "setTime: " + command );
  return command.toInt();
  }
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0