int ledPinG = D0;
int ledPinY = D1;
int ledPinB = D2;
void setup() {
Particle.subscribe("DIOT2018green",greenHandler);
Particle.subscribe("DIOT2018yellow",yellowHandler);
Particle.subscribe("DIOT2018blue",blueHandler);
Particle.subscribe("tag_dispensed",tag_dispensed);
pinMode( ledPinG , OUTPUT );
pinMode( ledPinY, OUTPUT );
pinMode(ledPinB, OUTPUT);
// digitalWrite(ledPinG, HIGH);
// digitalWrite(ledPinY, HIGH);
// digitalWrite(ledPinB, HIGH);
}
// LED Handlers
void greenHandler(const char *event, const char *data) {
if(data == "HIGH"){
digitalWrite(ledPinG, HIGH);
} else{
digitalWrite(ledPinG, LOW);
}
}
void yellowHandler(const char *event, const char *data) {
if(data == "HIGH"){
digitalWrite(ledPinY, HIGH);
} else{
digitalWrite(ledPinY, LOW);
}
}
void blueHandler(const char *event, const char *data) {
if(data == "HIGH"){
digitalWrite(ledPinB, HIGH);
} else{
digitalWrite(ledPinB, LOW);
}
}
// Indication of a New user LED Sequence via dispensed rfid tag
void tag_dispensed(const char *event, const char *data) {
if(data == "HIGH") {
digitalWrite(ledPinG, HIGH);
delay(1000);
digitalWrite(ledPinY, HIGH);
delay(1000);
digitalWrite(ledPinB, HIGH);
delay(1000);
digitalWrite(ledPinB, LOW);
delay(1000);
digitalWrite(ledPinY, LOW);
delay(1000);
digitalWrite(ledPinG, LOW);
delay(5000);
}
}
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. .