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.
test_capsense_main.h@2:d9745be6c253, 2022-08-04 (annotated)
- Committer:
- fionalin
- Date:
- Thu Aug 04 15:14:29 2022 -0400
- Revision:
- 2:d9745be6c253
hehe forgot to commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fionalin | 2:d9745be6c253 | 1 | #include "mbed.h" |
fionalin | 2:d9745be6c253 | 2 | #include "capsense.h" |
fionalin | 2:d9745be6c253 | 3 | #include <cstdio> |
fionalin | 2:d9745be6c253 | 4 | |
fionalin | 2:d9745be6c253 | 5 | const PinName CS_MEASURE = D2; |
fionalin | 2:d9745be6c253 | 6 | const PinName CS_SQUARE = D3; |
fionalin | 2:d9745be6c253 | 7 | |
fionalin | 2:d9745be6c253 | 8 | // main() runs in its own thread in the OS |
fionalin | 2:d9745be6c253 | 9 | int main() |
fionalin | 2:d9745be6c253 | 10 | { |
fionalin | 2:d9745be6c253 | 11 | CapSense cap_sense(CS_MEASURE, CS_SQUARE); |
fionalin | 2:d9745be6c253 | 12 | |
fionalin | 2:d9745be6c253 | 13 | while (true) { |
fionalin | 2:d9745be6c253 | 14 | cap_sense.start(); // turn it on |
fionalin | 2:d9745be6c253 | 15 | while (!cap_sense.try_measure()) {} |
fionalin | 2:d9745be6c253 | 16 | printf("%d\n", cap_sense.read_measurement()); |
fionalin | 2:d9745be6c253 | 17 | // we read a value, so safe to turn off |
fionalin | 2:d9745be6c253 | 18 | cap_sense.reset(); |
fionalin | 2:d9745be6c253 | 19 | wait_us(70000); // wait a bit to discharge |
fionalin | 2:d9745be6c253 | 20 | |
fionalin | 2:d9745be6c253 | 21 | } |
fionalin | 2:d9745be6c253 | 22 | } |
fionalin | 2:d9745be6c253 | 23 |