//2.3
int ledPin1 = D3;
int ledPin2 = D2;
void setup() {
pinMode(ledPin1, OUTPUT);
digitalWrite(ledPin1, LOW);
pinMode(ledPin2, OUTPUT);
digitalWrite(ledPin2, LOW);
Particle.function("led1", led1Control);
Particle.function("led2", led2Control);
}
void loop() {
}
int led1Control(String command)
{
int times = command.toInt();
for (int i=1; i<=times; i++) {
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
delay(500);
}
return 1;
}
int led2Control(String command)
{
int times = command.toInt();
for (int i=1; i<=times; i++) {
digitalWrite(ledPin2, HIGH);
delay(500);
digitalWrite(ledPin2, LOW);
delay(500);
}
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. .