A simple sawtooth waveform generator using analog output.
Dependencies: mbed
main.cpp@1:8901d4a806a8, 2014-12-18 (annotated)
- Committer:
- tbjazic
- Date:
- Thu Dec 18 07:34:06 2014 +0000
- Revision:
- 1:8901d4a806a8
- Parent:
- 0:95fd5a7168ac
Cast operator (float) added for accurate float division.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:95fd5a7168ac | 1 | #include "mbed.h" |
tbjazic | 0:95fd5a7168ac | 2 | |
tbjazic | 0:95fd5a7168ac | 3 | AnalogOut out(p18); |
tbjazic | 0:95fd5a7168ac | 4 | |
tbjazic | 0:95fd5a7168ac | 5 | int main() { |
tbjazic | 0:95fd5a7168ac | 6 | while(1) { |
tbjazic | 0:95fd5a7168ac | 7 | for (int i = 0; i < 10; i++) { |
tbjazic | 1:8901d4a806a8 | 8 | out = (float) i / 10; |
tbjazic | 0:95fd5a7168ac | 9 | wait_ms(1); |
tbjazic | 0:95fd5a7168ac | 10 | } |
tbjazic | 0:95fd5a7168ac | 11 | } |
tbjazic | 0:95fd5a7168ac | 12 | } |