Back to Parent

int solPin = D2;

bool shouldActivate = false;

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

  pinMode(solPin, OUTPUT);
}

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

  }
  delay( 100 );

}

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


int activateSolenoid( String command ){
  shouldActivate = true;
  return 1;

}
Click to Expand

Content Rating

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

0