Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FSR.h
00001 #ifndef FSR_H 00002 #define FSR_H 00003 00004 #include "mbed.h" 00005 00006 /** Force sensitive resistor class using an AnalogIn pin 00007 * 00008 * Example: 00009 * @code 00010 * #include "mbed.h" 00011 * #include "FSR.h" 00012 * FSR fsr(p20, 10); // Pin 20 is used as the AnalogIn pin and a 10k resistor is used as a voltage divider 00013 * int main(){ 00014 * while (1) 00015 * { 00016 * printf("The raw data is %f\n", fsr.readRaw()); 00017 * printf("The resistance of the FSR is %f\n", fsr.readFSRResistance()); 00018 * printf("The weight on the FSR is %f\n\n", fsr.readWeight()); 00019 * wait(0.3); //just here to slow down the output for easier reading 00020 * } 00021 * } 00022 * @endcode 00023 */ 00024 00025 class FSR 00026 { 00027 public: 00028 /** Create an FSR object 00029 * 00030 * @param Pin AnalogIn pin number 00031 * @param resistance resistance of the voltage divider resistor in k 00032 */ 00033 FSR(PinName Pin, float resistance); 00034 00035 /** Read the raw data 00036 * 00037 * @return the raw float data ranging from 0 to 1 00038 */ 00039 float readRaw(); 00040 00041 /** Read the resistance of the FSR 00042 * 00043 * @return the resistance of the FSR 00044 */ 00045 float readFSRResistance(); 00046 00047 /** Read the weight in N. 0 anyway if the weight is less than 100g 00048 * 00049 * @return the weight ranging from 100g to 10000g 00050 */ 00051 float readWeight(); 00052 protected: 00053 AnalogIn _ain; 00054 float _r; 00055 }; 00056 00057 #endif
Generated on Wed Jul 20 2022 21:37:27 by
1.7.2