int solPin = D2;
bool shouldActivate = false;
void setup()
{
pinMode(solPin, OUTPUT);
Particle.function( "activate", activateSolenoid );
}
void loop()
{
if( shouldActivate ){
doSolenoid( );
shouldActivate = false;
}
delay( 100 );
}
void doSolenoid( ){
for( int i = 0; i < 5; i++ )
{
digitalWrite(solPin, HIGH);
delay( 500) ;
digitalWrite(solPin, LOW);
delay( 500 );
}
}
int activateSolenoid( String command ){
int intensity = command.toInt();
if (intensity>10){
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!
You must login before you can post a comment. .