Back to Parent

int fsrPin = A0;
int fsrReading = 0;
int redPin = D2; 

int last_published = -1;
int interval=-1;

void setup() {
    pinMode(fsrPin, INPUT); 
    Particle.variable("fsr", &fsrReading, INT);
}

void loop() {
    fsrReading=analogRead(fsrPin); 
    if (fsrReading>1500)
    {
        Particle.publish( "fsr_happy", "happy" );
        analogWrite(redPin, 255);
        last_published=millis();
    }
    
    interval=millis()-last_published;
    if (interval>60000){
        Particle.publish( "fsr_sad", "sad" );
        last_published=millis();
    }
    delay(1000);
}
Click to Expand

Content Rating

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

0