int fanPin = D2;
bool shouldActivate = false;
void setup()
{
Particle.function( "activate", activateFan );
pinMode(fanPin, OUTPUT);
}
void loop()
{
if( shouldActivate ){
doFan( );
shouldActivate = false;
}
delay( 100 );
}
void doFan( ){
for( int i = 0; i < 5; i++ )
{
digitalWrite(fanPin, HIGH);
delay( 1000 ) ;
digitalWrite(fanPin, LOW);
delay( 1000 );
}
}
int activateFan( 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!
You must login before you can post a comment. .