int ledPin1 = D2;
int ledPin2 = D1;
void setup() {
pinMode( ledPin1, OUTPUT );
pinMode( ledPin2, OUTPUT );
digitalWrite( ledPin1, LOW );
digitalWrite( ledPin2, LOW );
//LED is initially turned off.
Particle.function( "led", ledControl );
//register function
}
int ledControl( String command ) {
int state = LOW;
if( command == "CALL" ) {
for ( int i = 0; i < 3; i++ ) {
digitalWrite( ledPin1, HIGH );
digitalWrite( ledPin2, HIGH );
delay( 500 );
digitalWrite(ledPin1, LOW );
digitalWrite(ledPin2, LOW );
delay( 500 );
}
}
else if( command == "CALL1" ) {
for ( int i = 0; i < 3; i++ ) {
digitalWrite( ledPin1, HIGH );
delay( 500 );
digitalWrite(ledPin1, LOW );
delay( 500 );
}
}
else if( command == "CALL2" ) {
for ( int i = 0; i < 3; i++ ) {
digitalWrite( ledPin2, HIGH );
delay( 500 );
digitalWrite(ledPin2, LOW );
delay( 500 );
}
}
else if( command == "HIGH" ) {
state = HIGH;
} else if( command == "LOW" ) {
state = LOW;
} else {
return -1;
}
digitalWrite( ledPin1, state );
digitalWrite( ledPin2, state );
return 1;
}
void loop() {
}
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. .