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.
Dependencies: mbed
Fork of Lab1_Part9 by
main.cpp@1:f21f8ffcd1b6, 2018-01-31 (annotated)
- Committer:
- bjs9
- Date:
- Wed Jan 31 18:06:54 2018 +0000
- Revision:
- 1:f21f8ffcd1b6
- Parent:
- 0:a0adc5ccd394
- Child:
- 2:29ca1063cbc3
Changes to code;
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 | 1:f21f8ffcd1b6 | 15 | for(int i= 0; i < 10; i++ ){ | 
| bjs9 | 0:a0adc5ccd394 | 16 | aout = sin(pi * i/10); | 
| bjs9 | 0:a0adc5ccd394 | 17 | value = sin(pi * i/10); | 
| bjs9 | 1:f21f8ffcd1b6 | 18 | //printf("aout = %1.2f volts\n",aout.read()); | 
| bjs9 | 1:f21f8ffcd1b6 | 19 | } | 
| bjs9 | 1:f21f8ffcd1b6 | 20 | for(int i = 10; i < 20; i++ ){ | 
| bjs9 | 1:f21f8ffcd1b6 | 21 | aout = -1 * sin(pi * i/10); | 
| bjs9 | 0:a0adc5ccd394 | 22 | } | 
| bjs9 | 0:a0adc5ccd394 | 23 | } | 
| bjs9 | 0:a0adc5ccd394 | 24 | } | 
