04-02 SawtoothWave
From Manuals
(Difference between revisions)
(Created page with 'This example outputs a saw tooth wave form on the DAC output. Image:BAM210_04_02.jpeg') |
|||
| Line 1: | Line 1: | ||
This example outputs a saw tooth wave form on the DAC output. | This example outputs a saw tooth wave form on the DAC output. | ||
| - | [[Image:BAM210_04_02. | + | /*Program Example 4.2: Sawtooth waveform on DAC output. View on oscilloscope |
| + | */ | ||
| + | #include "mbed.h" | ||
| + | AnalogOut Aout(DAC0); | ||
| + | float i; | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | while(1) { | ||
| + | for (i=0; i<1; i=i+0.1) { // i is incremented in steps of 0.1 | ||
| + | Aout=i; | ||
| + | wait(0.001); // wait 1 millisecond | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | [[Image:BAM210_04_02.png|center|]] | ||
Revision as of 15:01, 14 August 2014
This example outputs a saw tooth wave form on the DAC output.
/*Program Example 4.2: Sawtooth waveform on DAC output. View on oscilloscope
*/
#include "mbed.h"
AnalogOut Aout(DAC0);
float i;
int main()
{
while(1) {
for (i=0; i<1; i=i+0.1) { // i is incremented in steps of 0.1
Aout=i;
wait(0.001); // wait 1 millisecond
}
}
}

