Simon Ford
/
AnalogInDigitalOut
main.cpp@0:9e70f16bc114, 2009-09-03 (annotated)
- Committer:
- simon
- Date:
- Thu Sep 03 12:51:32 2009 +0000
- Revision:
- 0:9e70f16bc114
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:9e70f16bc114 | 1 | // example using same pin as analog and digital, sford |
simon | 0:9e70f16bc114 | 2 | |
simon | 0:9e70f16bc114 | 3 | #include "mbed.h" |
simon | 0:9e70f16bc114 | 4 | |
simon | 0:9e70f16bc114 | 5 | float do_something_analog() { |
simon | 0:9e70f16bc114 | 6 | AnalogIn x(p20); |
simon | 0:9e70f16bc114 | 7 | return x.read(); |
simon | 0:9e70f16bc114 | 8 | } |
simon | 0:9e70f16bc114 | 9 | |
simon | 0:9e70f16bc114 | 10 | void do_something_digital() { |
simon | 0:9e70f16bc114 | 11 | DigitalOut x(p20); |
simon | 0:9e70f16bc114 | 12 | x = 1; |
simon | 0:9e70f16bc114 | 13 | wait(0.5); |
simon | 0:9e70f16bc114 | 14 | x = 0; |
simon | 0:9e70f16bc114 | 15 | } |
simon | 0:9e70f16bc114 | 16 | |
simon | 0:9e70f16bc114 | 17 | int main() { |
simon | 0:9e70f16bc114 | 18 | while(1) { |
simon | 0:9e70f16bc114 | 19 | do_something_analog(); |
simon | 0:9e70f16bc114 | 20 | do_something_digital(); |
simon | 0:9e70f16bc114 | 21 | } |
simon | 0:9e70f16bc114 | 22 | } |