by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:6d4cf95d3f9a, 2012-08-31 (annotated)
- Committer:
- robt
- Date:
- Fri Aug 31 15:25:50 2012 +0000
- Revision:
- 0:6d4cf95d3f9a
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:6d4cf95d3f9a | 1 | /*Program Example 4.2: Sawtooth waveform on DAC output. View on oscilloscope |
robt | 0:6d4cf95d3f9a | 2 | */ |
robt | 0:6d4cf95d3f9a | 3 | #include "mbed.h" |
robt | 0:6d4cf95d3f9a | 4 | AnalogOut Aout(p18); |
robt | 0:6d4cf95d3f9a | 5 | float i; |
robt | 0:6d4cf95d3f9a | 6 | |
robt | 0:6d4cf95d3f9a | 7 | int main() |
robt | 0:6d4cf95d3f9a | 8 | { |
robt | 0:6d4cf95d3f9a | 9 | while(1) { |
robt | 0:6d4cf95d3f9a | 10 | for (i=0; i<1; i=i+0.1) { // i is incremented in steps of 0.1 |
robt | 0:6d4cf95d3f9a | 11 | Aout=i; |
robt | 0:6d4cf95d3f9a | 12 | wait(0.001); // wait 1 millisecond |
robt | 0:6d4cf95d3f9a | 13 | } |
robt | 0:6d4cf95d3f9a | 14 | } |
robt | 0:6d4cf95d3f9a | 15 | } |