
using resistor and DAC0_OUT to create a sawtooth wave
main.cpp@1:a14b50308ca9, 2020-04-15 (annotated)
- Committer:
- namcheol
- Date:
- Wed Apr 15 07:33:40 2020 +0000
- Revision:
- 1:a14b50308ca9
- Parent:
- 0:f31836d48420
lab02-sawtooth-wave
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dshin | 0:f31836d48420 | 1 | #include "mbed.h" |
dshin | 0:f31836d48420 | 2 | |
namcheol | 1:a14b50308ca9 | 3 | AnalogOut vout(DAC0_OUT); //vout = DAC0_OUT |
dshin | 0:f31836d48420 | 4 | |
dshin | 0:f31836d48420 | 5 | int main() |
dshin | 0:f31836d48420 | 6 | { |
namcheol | 1:a14b50308ca9 | 7 | float f; |
namcheol | 1:a14b50308ca9 | 8 | int t = 0, i; |
namcheol | 1:a14b50308ca9 | 9 | |
namcheol | 1:a14b50308ca9 | 10 | printf("Time, Vout\r\n"); |
dshin | 0:f31836d48420 | 11 | while (true) { |
namcheol | 1:a14b50308ca9 | 12 | for(f = 0.0; f < 1.1; f += 0.1) { |
namcheol | 1:a14b50308ca9 | 13 | vout = f; |
namcheol | 1:a14b50308ca9 | 14 | for(i = 0; i < 10; i++) |
namcheol | 1:a14b50308ca9 | 15 | printf("%d, %f\r\n", t++, f*3.3); //vout = f * 3.3 |
namcheol | 1:a14b50308ca9 | 16 | } |
namcheol | 1:a14b50308ca9 | 17 | |
dshin | 0:f31836d48420 | 18 | } |
dshin | 0:f31836d48420 | 19 | } |