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.
touch1.cpp@0:cdbd21489e81, 2010-11-30 (annotated)
- Committer:
- bzhang10
- Date:
- Tue Nov 30 22:03:27 2010 +0000
- Revision:
- 0:cdbd21489e81
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bzhang10 | 0:cdbd21489e81 | 1 | #include "mbed.h" |
| bzhang10 | 0:cdbd21489e81 | 2 | |
| bzhang10 | 0:cdbd21489e81 | 3 | #define numsamples 1 |
| bzhang10 | 0:cdbd21489e81 | 4 | |
| bzhang10 | 0:cdbd21489e81 | 5 | AnalogIn input1(p15); |
| bzhang10 | 0:cdbd21489e81 | 6 | DigitalIn charger1(p16); |
| bzhang10 | 0:cdbd21489e81 | 7 | DigitalOut ground1(p17); |
| bzhang10 | 0:cdbd21489e81 | 8 | |
| bzhang10 | 0:cdbd21489e81 | 9 | int touchSense1(void) { |
| bzhang10 | 0:cdbd21489e81 | 10 | float sample; |
| bzhang10 | 0:cdbd21489e81 | 11 | ground1 = 0; |
| bzhang10 | 0:cdbd21489e81 | 12 | charger1.mode(PullUp); |
| bzhang10 | 0:cdbd21489e81 | 13 | charger1.mode(PullNone); |
| bzhang10 | 0:cdbd21489e81 | 14 | sample=input1.read(); |
| bzhang10 | 0:cdbd21489e81 | 15 | if (sample < 0.3) { |
| bzhang10 | 0:cdbd21489e81 | 16 | return 1; |
| bzhang10 | 0:cdbd21489e81 | 17 | } else { |
| bzhang10 | 0:cdbd21489e81 | 18 | return 0; |
| bzhang10 | 0:cdbd21489e81 | 19 | } |
| bzhang10 | 0:cdbd21489e81 | 20 | } |