int happyled = D0;
int timer = 0;
long currentTime = 0;
long previousTime = 0;
void setup()
{
pinMode(happyled, OUTPUT);
Particle.function("happyfunc", happyfunc);
Serial.begin(9600);
digitalWrite(happyled, HIGH);
delay(2000);
digitalWrite(happyled, LOW);
delay(2000);
}
void loop() {
}
int happyfunc(String args) {
currentTime = millis();
if(currentTime - previousTime <= 15000) {
for(int i = 0; i < 10; i++) {
digitalWrite(happyled, HIGH);
delay(200);
digitalWrite(happyled, LOW);
delay(100);
}
}
else{
for(int i = 0; i < 5; i++) {
digitalWrite(happyled, HIGH);
delay(600);
digitalWrite(happyled, LOW);
delay(200);
}
}
previousTime = currentTime;
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. .