Back to Parent

//Deep Dive for Map

//People counter -> radar sensor
int countLowLED = D1;
int countMedLED = D1;
int countHighLED = D1;

//Trash maintenance request -> ir sensor for trash can
int trash1LED = D1;
int trash2LED = -1;
int trash3LED = -1;
int trash4LED = -1;

//Person maintenance request -> button
//no LED, will send maintenance request to park managers
int map1LED = D1;
int map2LED = -1;
int map3LED = -1;
int map4LED = -1;

//Animal Repellent -> piezo
//no LED, will constantly buzz

void setup() {
    Particle.subscribe("counter", counter, ALL_DEVICES);
    Particle.subscribe("trashFull", trashFull, ALL_DEVICES);
    Particle.subscribe("trashEmpty", trashEmpty, ALL_DEVICES);
    
    //counter
    pinMode(countLowLED, OUTPUT);
    pinMode(countMedLED, OUTPUT);
    pinMode(countHighLED, OUTPUT);
    
    //trash
    pinMode(trash1LED, OUTPUT);
    pinMode(trash2LED, OUTPUT);
    pinMode(trash3LED, OUTPUT);
    pinMode(trash4LED, OUTPUT);
    
    //button
    pinMode(map1LED, OUTPUT);
    pinMode(map2LED, OUTPUT);
    pinMode(map3LED, OUTPUT);
    pinMode(map4LED, OUTPUT);

}

void loop() {

}


void counter(const char *event, const char *data){
    if (strcmp(data, "1")==0){
        digitalWrite(countLowLED, HIGH);
        digitalWrite(countMedLED, LOW);
        digitalWrite(countHighLED, LOW);
    }
    
    if (strcmp(data, "2")==0){
        digitalWrite(countLowLED, LOW);
        digitalWrite(countMedLED, HIGH);
        digitalWrite(countHighLED, LOW);
    }
    
    if (strcmp(data, "3")==0){
        digitalWrite(countLowLED, LOW);
        digitalWrite(countMedLED, LOW);
        digitalWrite(countHighLED, HIGH);
    }
}

void trashFull(const char *event, const char *data){
    if (strcmp(data, "trash1")==0){
        digitalWrite(trash1LED, HIGH);
        digitalWrite(map1LED, HIGH);
    }
    if (strcmp(data, "trash2")==0){
        digitalWrite(trash2LED, HIGH);
        digitalWrite(map2LED, HIGH);
    }
    if (strcmp(data, "trash3")==0){
        digitalWrite(trash3LED, HIGH);
        digitalWrite(map3LED, HIGH);
    }
    if (strcmp(data, "trash4")==0){
        digitalWrite(trash4LED, HIGH);
        digitalWrite(map4LED, HIGH);
    }
}

void trashEmpty(const char *event, const char *data){
    if (strcmp(data, "trash1")==0){
        digitalWrite(trash1LED, LOW);
        digitalWrite(map1LED, LOW);
    }
    if (strcmp(data, "trash2")==0){
        digitalWrite(trash2LED, LOW);
        digitalWrite(map2LED, LOW);
    }
    if (strcmp(data, "trash3")==0){
        digitalWrite(trash3LED, LOW);
        digitalWrite(map3LED, LOW);
    }
    if (strcmp(data, "trash4")==0){
        digitalWrite(trash4LED, LOW);
        digitalWrite(map4LED, LOW);
    }
}
Click to Expand

Content Rating

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

0