final code (doesnt work)

Dependencies:   mbed Servo C12832_lcd

Committer:
mazmonem
Date:
Fri Nov 23 16:37:21 2018 +0000
Revision:
1:52cda602892c
Parent:
0:65b5886093c5
final code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazmonem 0:65b5886093c5 1 #ifndef FSR_H
mazmonem 0:65b5886093c5 2 #define FSR_H
mazmonem 0:65b5886093c5 3
mazmonem 0:65b5886093c5 4 #include "mbed.h"
mazmonem 0:65b5886093c5 5
mazmonem 0:65b5886093c5 6 /** Force sensitive resistor class using an AnalogIn pin
mazmonem 0:65b5886093c5 7 *
mazmonem 0:65b5886093c5 8 * Example:
mazmonem 0:65b5886093c5 9 * @code
mazmonem 0:65b5886093c5 10 * #include "mbed.h"
mazmonem 0:65b5886093c5 11 * #include "FSR.h"
mazmonem 0:65b5886093c5 12 * FSR fsr(p20, 10); // Pin 20 is used as the AnalogIn pin and a 10k resistor is used as a voltage divider
mazmonem 0:65b5886093c5 13 * int main(){
mazmonem 0:65b5886093c5 14 * while (1)
mazmonem 0:65b5886093c5 15 * {
mazmonem 0:65b5886093c5 16 * printf("The raw data is %f\n", fsr.readRaw());
mazmonem 0:65b5886093c5 17 * printf("The resistance of the FSR is %f\n", fsr.readFSRResistance());
mazmonem 0:65b5886093c5 18 * printf("The weight on the FSR is %f\n\n", fsr.readWeight());
mazmonem 0:65b5886093c5 19 * wait(0.3); //just here to slow down the output for easier reading
mazmonem 0:65b5886093c5 20 * }
mazmonem 0:65b5886093c5 21 * }
mazmonem 0:65b5886093c5 22 * @endcode
mazmonem 0:65b5886093c5 23 */
mazmonem 0:65b5886093c5 24
mazmonem 0:65b5886093c5 25 class FSR
mazmonem 0:65b5886093c5 26 {
mazmonem 0:65b5886093c5 27 public:
mazmonem 0:65b5886093c5 28 /** Create an FSR object
mazmonem 0:65b5886093c5 29 *
mazmonem 0:65b5886093c5 30 * @param Pin AnalogIn pin number
mazmonem 0:65b5886093c5 31 * @param resistance resistance of the voltage divider resistor in k
mazmonem 0:65b5886093c5 32 */
mazmonem 0:65b5886093c5 33 FSR(PinName Pin, float resistance);
mazmonem 0:65b5886093c5 34
mazmonem 0:65b5886093c5 35 /** Read the raw data
mazmonem 0:65b5886093c5 36 *
mazmonem 0:65b5886093c5 37 * @return the raw float data ranging from 0 to 1
mazmonem 0:65b5886093c5 38 */
mazmonem 0:65b5886093c5 39 float readRaw();
mazmonem 0:65b5886093c5 40
mazmonem 0:65b5886093c5 41 /** Read the resistance of the FSR
mazmonem 0:65b5886093c5 42 *
mazmonem 0:65b5886093c5 43 * @return the resistance of the FSR
mazmonem 0:65b5886093c5 44 */
mazmonem 0:65b5886093c5 45 float readFSRResistance();
mazmonem 0:65b5886093c5 46
mazmonem 0:65b5886093c5 47 /** Read the weight in N. 0 anyway if the weight is less than 100g
mazmonem 0:65b5886093c5 48 *
mazmonem 0:65b5886093c5 49 * @return the weight ranging from 100g to 10000g
mazmonem 0:65b5886093c5 50 */
mazmonem 0:65b5886093c5 51 float readWeight();
mazmonem 0:65b5886093c5 52 protected:
mazmonem 0:65b5886093c5 53 AnalogIn _ain;
mazmonem 0:65b5886093c5 54 float _r;
mazmonem 0:65b5886093c5 55 };
mazmonem 0:65b5886093c5 56
mazmonem 0:65b5886093c5 57 #endif