Dependencies:   mbed

Use

The AnalogOut API is used to convert a digital number to an analog value. The output value is set as a percentage of the supply voltage. The percentage is specified as a floating point number between 0 to 1. This example demonstrates a ramp from 0 to 1 in 10% increments.

Note

Not all boards support analog output. The board must have a Digital to Analog Converter (DAC) to use the API. The compiler will throw a warning if the AnalogOut API is not available for a target board. Alternatively the target platform will list its components on the Platforms page.

API

API reference.

Import librarymbed

No documentation found.
Committer:
mbedAustin
Date:
Mon Sep 22 20:19:09 2014 +0000
Revision:
4:6c49a5b891dc
Parent:
3:8b80a1c145ea
removed print statement

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:f739c4adb6ed 1 #include "mbed.h"
mbed_official 0:f739c4adb6ed 2
mbedAustin 3:8b80a1c145ea 3 AnalogOut signal(PTE30); // change this to match your board
mbedAustin 2:0c7214ae3894 4
mbedAustin 2:0c7214ae3894 5 // ramp up the output in 10% incriments, drop to zero, repeat
mbed_official 0:f739c4adb6ed 6 int main() {
mbed_official 0:f739c4adb6ed 7 while(1) {
mbed_official 0:f739c4adb6ed 8 for(float i=0.0; i<1.0; i+=0.1) {
mbed_official 0:f739c4adb6ed 9 signal = i;
mbedAustin 3:8b80a1c145ea 10 wait(0.1);
mbedAustin 3:8b80a1c145ea 11 }
mbed_official 0:f739c4adb6ed 12 }
mbed_official 0:f739c4adb6ed 13 }