Jhon Plantikow
/
MensureCapacitor
User a frequecy of response using LM555 in circuit to mensure the capacitor unit
main.cpp@0:8b2d83f469fa, 2015-06-25 (annotated)
- Committer:
- jhon309
- Date:
- Thu Jun 25 00:26:16 2015 +0000
- Revision:
- 0:8b2d83f469fa
.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:8b2d83f469fa | 1 | #include "mbed.h" |
jhon309 | 0:8b2d83f469fa | 2 | #include "capSense.h" |
jhon309 | 0:8b2d83f469fa | 3 | #include <ctype.h> |
jhon309 | 0:8b2d83f469fa | 4 | |
jhon309 | 0:8b2d83f469fa | 5 | |
jhon309 | 0:8b2d83f469fa | 6 | #define RA 51000 // ohms |
jhon309 | 0:8b2d83f469fa | 7 | #define RB 22000 // ohms |
jhon309 | 0:8b2d83f469fa | 8 | #define PERIOD 2000000 //us |
jhon309 | 0:8b2d83f469fa | 9 | |
jhon309 | 0:8b2d83f469fa | 10 | |
jhon309 | 0:8b2d83f469fa | 11 | Serial pc(SERIAL_TX, SERIAL_RX); |
jhon309 | 0:8b2d83f469fa | 12 | CapSense cap(RA, RB, PERIOD, PB_9); |
jhon309 | 0:8b2d83f469fa | 13 | |
jhon309 | 0:8b2d83f469fa | 14 | int main() |
jhon309 | 0:8b2d83f469fa | 15 | { |
jhon309 | 0:8b2d83f469fa | 16 | while(1) |
jhon309 | 0:8b2d83f469fa | 17 | { |
jhon309 | 0:8b2d83f469fa | 18 | float capacitance = cap.measure(); |
jhon309 | 0:8b2d83f469fa | 19 | pc.printf("%.4f#%.2f\n", capacitance,(float)cap._count/1.999); |
jhon309 | 0:8b2d83f469fa | 20 | } |
jhon309 | 0:8b2d83f469fa | 21 | } |