Yifan Chen - skill dev 4

Made by yifanch2

Created: December 2nd, 2021

0
2021年12月2日
Yifan Chen - https://youtu.be/C4ANTlklnyY
0
int servoPin = A3;
Servo myServo;
int servoPos = 0;

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("servo", servoControl);
   
   // Keep a cloud variable for the current position
  Particle.variable(  "servoPos" , &servoPos , INT );
}

void loop() {

}

int servoControl(String command)
{
    // Convert
   int newPos = command.toInt();
   // Make sure it is in the right range
   // And set the position
   servoPos = constrain( newPos, 0 , 360);

   // Set the servo
   myServo.write( servoPos );

   // done
   return 1;
}
Click to Expand
0

Each color represents certain weather, for example, yellow represents sunny, brown represents cloudy, and orange represents rainy. 

input = 0 => sunny ; 

input = 90 => brown;

input = 180 => orange;

x