04-01 DACOutput
From Manuals
(Difference between revisions)
(Created page with 'This example outputs 3 different values to the Digital to Analog Converter (DAC) every 2 seconds. It outputs 0.825V, 1.65V, and 2.475V. Image:BAM210_04_01.jpeg') |
|||
| Line 1: | Line 1: | ||
This example outputs 3 different values to the Digital to Analog Converter (DAC) every 2 seconds. It outputs 0.825V, 1.65V, and 2.475V. | This example outputs 3 different values to the Digital to Analog Converter (DAC) every 2 seconds. It outputs 0.825V, 1.65V, and 2.475V. | ||
| + | |||
| + | /*Program Example 4.1: Three values of DAC are output in turn on Pin DAC0. Read the output on a DVM. | ||
| + | */ | ||
| + | #include "mbed.h" | ||
| + | AnalogOut Aout(DAC0); //create an analog output on pin DAC0 | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | while(1) { | ||
| + | Aout=0.25; // 0.25*3.3V = 0.825V | ||
| + | wait(2); | ||
| + | Aout=0.5; // 0.5*3.3V = 1.65V | ||
| + | wait(2); | ||
| + | Aout=0.75; // 0.75*3.3V = 2.475V | ||
| + | wait(2); | ||
| + | } | ||
| + | } | ||
[[Image:BAM210_04_01.jpeg|center|]] | [[Image:BAM210_04_01.jpeg|center|]] | ||
Revision as of 14:42, 14 August 2014
This example outputs 3 different values to the Digital to Analog Converter (DAC) every 2 seconds. It outputs 0.825V, 1.65V, and 2.475V.
/*Program Example 4.1: Three values of DAC are output in turn on Pin DAC0. Read the output on a DVM.
*/
#include "mbed.h"
AnalogOut Aout(DAC0); //create an analog output on pin DAC0
int main()
{
while(1) {
Aout=0.25; // 0.25*3.3V = 0.825V
wait(2);
Aout=0.5; // 0.5*3.3V = 1.65V
wait(2);
Aout=0.75; // 0.75*3.3V = 2.475V
wait(2);
}
}

