Lee Nam Cheol
/
lab02-sawtooth-wave
using resistor and DAC0_OUT to create a sawtooth wave
Revision 1:a14b50308ca9, committed 2020-04-15
- Comitter:
- namcheol
- Date:
- Wed Apr 15 07:33:40 2020 +0000
- Parent:
- 0:f31836d48420
- Commit message:
- lab02-sawtooth-wave
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f31836d48420 -r a14b50308ca9 main.cpp --- a/main.cpp Sun Mar 29 19:41:28 2020 +0000 +++ b/main.cpp Wed Apr 15 07:33:40 2020 +0000 @@ -1,18 +1,19 @@ #include "mbed.h" -// https://os.mbed.com/docs/mbed-os/v5.15/tools/creating-a-new-program.html - -Serial pc(USBTX, USBRX, 115200); // baud rate 115200 -DigitalOut led(LED1); // led = LED1 +AnalogOut vout(DAC0_OUT); //vout = DAC0_OUT int main() { + float f; + int t = 0, i; + + printf("Time, Vout\r\n"); while (true) { - led = 0; - printf("LED1 is ON\r\n"); - thread_sleep_for(500); - led = 1; - printf("LED1 is OFF\r\n"); - thread_sleep_for(500); + for(f = 0.0; f < 1.1; f += 0.1) { + vout = f; + for(i = 0; i < 10; i++) + printf("%d, %f\r\n", t++, f*3.3); //vout = f * 3.3 + } + } } \ No newline at end of file