int led1Pin = D3;
int led2Pin = D4;
int led1Control(String command) {
int times = atoi(command);
for(int i = 0; i < times; i++) {
digitalWrite(led1Pin, HIGH);
delay(500);
digitalWrite(led1Pin, LOW);
delay(500);
}
return 1;
}
int led2Control(String command) {
int times = atoi(command);
for(int i = 0; i < times; i++) {
digitalWrite(led2Pin, HIGH);
delay(500);
digitalWrite(led2Pin, LOW);
delay(500);
}
return 1;
}
void setup() {
Particle.function("led1", led1Control);
Particle.function("led2", led2Control);
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
}
void loop() {
}
Click to Expand