// Define a pin that we'll place the FSR on
// Remember to add a 10K Ohm pull-down resistor too.
int fsrPin = A0;
// Create a variable to hold the FSR reading
int fsrReading = 0;
// Define a pin we'll place an LED on
int ledPinA = D2;
int ledPinB = D3;
int ledPinC = D4;
void setup()
{
// Set up the LED for output
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
// Create a cloud variable of type integer
// called 'light' mapped to photoCellReading
Particle.variable("force", &fsrReading, INT);
}
void loop()
{
fsrReading = analogRead(fsrPin);
if (fsrReading>500 && fsrReading<2000)
{
digitalWrite(ledPinA, HIGH);
}
else if (fsrReading>2000 && fsrReading<3000)
{
digitalWrite(ledPinA, HIGH);
digitalWrite(ledPinB, HIGH);
}
else if (fsrReading>3000)
{
digitalWrite(ledPinA, HIGH);
digitalWrite(ledPinB, HIGH);
digitalWrite(ledPinC, HIGH);
}
else
{
digitalWrite(ledPinA, LOW);
digitalWrite(ledPinB, LOW);
digitalWrite(ledPinC, LOW);
}
}
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. .