Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Ingo Lohs
Published © GPL3+

Flexible Touch Sensor FSR 402 from IEFSR.com

The FSR 402 model is a single-zone Force Sensing Resistor® optimized for use in human touch control of electronic devices.

BeginnerProtip24 minutes2,376

Things used in this project

Hardware components

Force Sensing Resistor FSR 402
×1
Photon
Particle Photon
×1
Jumper wires (generic)
Jumper wires (generic)
2 pieces
×1
Breadboard (generic)
Breadboard (generic)
optional
×1

Story

Read more

Code

FSR 402 - put the LED on/off

C/C++
// Touch-Sensor Particle Photon - works with v0.7.0 without Libaries
// Ingo Lohs, v1.0 v. 08.04.2018
// after the touch of the sensor, the Photon LED is on

// Definitions
const int TOUCH_PIN_IN = D4;   // Pin connected to SIG at Touch-Sensor
const int LED_PIN = D7;        // LED pin

unsigned long lastmillis = 0;  // time for interation the loop


void setup() 
{
  pinMode(TOUCH_PIN_IN, INPUT);
  pinMode(LED_PIN, OUTPUT);
}


void loop() 
{
    if ((millis() - lastmillis) > 10) { // play with the millis
        lastmillis = millis();
        readData();
    }
}


void readData() {

    int proximity = digitalRead(TOUCH_PIN_IN); // Read the state of the sensor
    
        if (proximity == HIGH) 
        {
        digitalWrite(LED_PIN, LOW); // Turn the LED off
        }
        else
        {
        digitalWrite(LED_PIN, HIGH); // Turn the LED on
        }    
}

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments