Back to Parent

int solPin = D2;

bool shouldActivate = false;

void setup()
{
  Particle.function( "windIntensity", activateSolenoid );

  pinMode(solPin, OUTPUT);
}

void loop()
{
  if( shouldActivate ){
    doSolenoid(  );
    shouldActivate = false;

  }
  delay( 100 );

}

void doSolenoid( ){
  for( int i = 0; i < 5; i++ )
  {
    digitalWrite(solPin, HIGH);
    delay( 2000 ) ;
    digitalWrite(solPin, LOW);
    delay( 1000 );
  }
}


int activateSolenoid( String command ){
    int intensity = command.toInt();
    if (intensity>2000){
        shouldActivate = true;
    }
  return 13;

}
Click to Expand

Content Rating

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

0