Back to Parent

#include "rgb-controls.h"

using namespace RGBControls;

Led led(D0, D1,D2);

Color red(255,0,0);

Color green(0,255,0);

Color blue(0,0,255);

Color dark(0,0,0);

Color colors[3] = {red, green, blue};

unsigned long lastTime = 0;

int prdTime;

void getBus(){

Particle.publish("busgazer", PRIVATE);

}

void handleBusgazerReceived(const char *event, const char *data){

prdTime = String( data ).toInt();

}

void setup(){

Serial.begin(9600);

Particle.subscribe("hook-response/busgazer", handleBusgazerReceived, MY_DEVICES);

getBus();

Serial.println(prdTime);

}

void loop(){

unsigned long now = millis();

if ((now - lastTime) >= 120000){

lastTime = now;

getBus();

Serial.println(prdTime);

}

if (prdTime >= 12){

led.fade(colors,3,5000);}

else if(prdTime<=12 and prdTime>=6){

led.fade(red,dark,2000);

}

}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0