// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 12
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int fsrPin0 = A0;
int fsrPin1 = A1;
int fsrPin2 = A2;
// Create a variable to hold the FSR reading
int fsrReading0 = 0;
int fsrReading1 = 0;
int fsrReading2 = 0;
// Define a pin we'll place an LED on
int ledPin = D1;
// Create a variable to store the LED brightness.
int ledBrightness = 0;
int ttPin = D2;
int thresholdValue = 200;
void setup()
{
pinMode( ttPin , INPUT_PULLUP);
pinMode(fsrPin0,INPUT);
pinMode(fsrPin1,INPUT);
pinMode(fsrPin2,INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int istouch = digitalRead( ttPin );
fsrReading0 = analogRead(fsrPin0);
fsrReading1 = analogRead(fsrPin1);
fsrReading2 = analogRead(fsrPin2);
// if( istouch == LOW )
if(fsrReading0 > thresholdValue || fsrReading1 > thresholdValue ||fsrReading2 > thresholdValue)
{
digitalWrite( ledPin, HIGH);
Particle.publish("sleepstar/2p", "sleep_t");
delay(500);
}else{
digitalWrite( ledPin, LOW);
Particle.publish("sleepstar/2p", "sleep_ts");
}
// if(fsrReading > thresholdValue){
// Particle.publish("sleepstar/2p", "stop");
// delay(100);
// }
//
//
// else {
// digitalWrite(ledPin,LOW);
//
// delay(100);
// }
}
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. .