![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Lab1_Part9
main.cpp@0:a0adc5ccd394, 2018-01-31 (annotated)
- Committer:
- bjs9
- Date:
- Wed Jan 31 17:56:24 2018 +0000
- Revision:
- 0:a0adc5ccd394
Lab1_Part9;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bjs9 | 0:a0adc5ccd394 | 1 | #include "mbed.h" |
bjs9 | 0:a0adc5ccd394 | 2 | #include <math.h> |
bjs9 | 0:a0adc5ccd394 | 3 | |
bjs9 | 0:a0adc5ccd394 | 4 | #ifndef M_PI |
bjs9 | 0:a0adc5ccd394 | 5 | #define M_PI 3.1415 |
bjs9 | 0:a0adc5ccd394 | 6 | #endif |
bjs9 | 0:a0adc5ccd394 | 7 | |
bjs9 | 0:a0adc5ccd394 | 8 | AnalogOut aout(p18); |
bjs9 | 0:a0adc5ccd394 | 9 | float value = 0.0f; |
bjs9 | 0:a0adc5ccd394 | 10 | |
bjs9 | 0:a0adc5ccd394 | 11 | int main() |
bjs9 | 0:a0adc5ccd394 | 12 | { |
bjs9 | 0:a0adc5ccd394 | 13 | const double pi = 3.141592653589793238462; |
bjs9 | 0:a0adc5ccd394 | 14 | while (1) { |
bjs9 | 0:a0adc5ccd394 | 15 | for(int i= 0; i < 20; i++ ){ |
bjs9 | 0:a0adc5ccd394 | 16 | aout = sin(pi * i/10); |
bjs9 | 0:a0adc5ccd394 | 17 | value = sin(pi * i/10); |
bjs9 | 0:a0adc5ccd394 | 18 | printf("aout = %1.2f volts\n",aout.read()); |
bjs9 | 0:a0adc5ccd394 | 19 | wait(0.01); |
bjs9 | 0:a0adc5ccd394 | 20 | } |
bjs9 | 0:a0adc5ccd394 | 21 | } |
bjs9 | 0:a0adc5ccd394 | 22 | } |