int vPump = D0;
int atHome = D1;
unsigned lastBusTime = 0;
bool busHere = false;
void setup()
{
pinMode(vPump, OUTPUT);
pinMode(atHome, INPUT_PULLUP);
Particle.subscribe("bustime", callballonpop);
}
void loop()
{
if (busHere == TRUE)
{ if (millis() - lastBusTime < 5000)
{
balooonpop();
}
else
{
digitalWrite(vPump, LOW);
busHere == FALSE;
}
}
}
void callballonpop(const char *event, const char *data)
{
lastBusTime = millis();
busHere = TRUE;
loop();
}
void balooonpop()
{ if (digitalRead(D1) == LOW)
{
digitalWrite(vPump, HIGH);
}
else
{
digitalWrite(vPump, LOW);
}
}
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. .