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.
Dependents: K64F-RTOS-MQTT-Example
Fork of FSR by
FSR.cpp
00001 #include "FSR.h" 00002 #include "mbed.h" 00003 00004 FSR::FSR(PinName pin, float resistance) : _ain(pin), _r(resistance) 00005 { 00006 } 00007 00008 float FSR::readRaw() 00009 { 00010 float read = _ain; 00011 return read; 00012 } 00013 00014 float* FSR::readFSRResistance() 00015 { 00016 float read = _ain; 00017 //float* obj=new float; 00018 //obj=(_r * 1 / read - _r); 00019 //return obj; 00020 float t=(_r * 1 / read - _r); 00021 return &t; 00022 } 00023 00024 float FSR::readWeight() 00025 { 00026 float read = _ain; 00027 float rfsr = _r * 1 / read - _r; 00028 float slope = (4 - 2) / (log10(6.2) - log10(0.25)); 00029 float a = log10(rfsr); 00030 if (a < log10(6.2)) 00031 { 00032 return pow(10, ((log10(6.2) - a) * slope + 2)); 00033 } 00034 else 00035 { 00036 return 0; 00037 } 00038 }
Generated on Tue Jul 12 2022 16:19:56 by
1.7.2
