Back to Parent

int buttonPin = D3;
int servoPin = D2;
Servo myServo;
int servoPos = 0;
long lastPublishedAt = 0;
// this is the time delay before we should publish a new event
// from this device
int publishAfter = 10000;
bool state = false;



void setup() 
{
  pinMode(buttonPin, INPUT_PULLUP);
  myServo.attach( D2 );
  Particle.subscribe(  "diot/2019/smartstudio/supporter" , handleSharedEventPrint);
  Particle.variable(  "servoPos" , &servoPos , INT );
}


void loop() 
{
 
}




// A character array that contains the data published in the event we're responding to.
void handleSharedEventPrint(const char *event, const char *data)
{
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
  delay(1000);
  myServo.write( 180 );
  delay(1000);
  myServo.write( 0 );
}
Click to Expand

Content Rating

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

0