FSR

Dependents:   FSR_hello_world FINAL_PROJECT Pousse_seringue_Ulg 0__Pousse_seringue ... more

Embed: (wiki syntax)

« Back to documentation index

FSR Class Reference

FSR Class Reference

Force sensitive resistor class using an AnalogIn pin. More...

#include <FSR.h>

Public Member Functions

 FSR (PinName Pin, float resistance)
 Create an FSR object.
float readRaw ()
 Read the raw data.
float readFSRResistance ()
 Read the resistance of the FSR.
float readWeight ()
 Read the weight in N.

Detailed Description

Force sensitive resistor class using an AnalogIn pin.

Example:

 #include "mbed.h"
 #include "FSR.h"
 FSR fsr(p20, 10); // Pin 20 is used as the AnalogIn pin and a 10k resistor is used as a voltage divider
 int main(){
     while (1)
     {
         printf("The raw data is %f\n", fsr.readRaw());
         printf("The resistance of the FSR is %f\n", fsr.readFSRResistance());
         printf("The weight on the FSR is %f\n\n", fsr.readWeight());
         wait(0.3); //just here to slow down the output for easier reading
     }
 }

Definition at line 25 of file FSR.h.


Constructor & Destructor Documentation

FSR ( PinName  Pin,
float  resistance 
)

Create an FSR object.

Parameters:
PinAnalogIn pin number
resistanceresistance of the voltage divider resistor in k

Definition at line 4 of file FSR.cpp.


Member Function Documentation

float readFSRResistance (  )

Read the resistance of the FSR.

Returns:
the resistance of the FSR

Definition at line 14 of file FSR.cpp.

float readRaw (  )

Read the raw data.

Returns:
the raw float data ranging from 0 to 1

Definition at line 8 of file FSR.cpp.

float readWeight (  )

Read the weight in N.

0 anyway if the weight is less than 100g

Returns:
the weight ranging from 100g to 10000g

Definition at line 20 of file FSR.cpp.