int solPin = D2;
bool doSolenoidActionSun = false;
bool doSolenoidActionRain = false;
void setup() {
Serial.begin( 9600 );
pinMode( solPin, OUTPUT );
Particle.function( "Sunny", handleDoSolenoidSun );
Particle.function( "Raining", handleDoSolenoidRain );
}
void loop(){
if( doSolenoidActionSun ){
Serial.println( "Sunny" );
digitalWrite( solPin, HIGH );
}
if( doSolenoidActionRain ){
Serial.println( "Raining" );
digitalWrite( solPin, LOW );
}
doSolenoidActionSun = false;
doSolenoidActionRain = false;
}
int handleDoSolenoidSun( String cmd ){
doSolenoidActionSun = true;
return 1;
}
int handleDoSolenoidRain( String cmd ){
doSolenoidActionRain = 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. .