AnalogOut
The AnalogOut Interface is used to set the voltage of an analog output pin.
Hello World!
// Create a sawtooth wave
#include "mbed.h"
AnalogOut signal(p18);
int main() {
while(1) {
for(float i=0.0; i<1.0; i+=0.1) {
signal = i;
wait(0.0001);
}
}
}
API
| AnalogOut | An analog output, used for setting the voltage on a pin |
| Functions | |
| AnalogOut | Create an AnalogOut connected to the specified pin |
| write | Set the output voltage, specified as a percentage (float) |
| write_u16 | Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF] |
| read | Return the current output voltage setting, measured as a percentage (float) |
| operator= | An operator shorthand for write() |
| operator float() | An operator shorthand for read() |
Details
The AnalogOut Interface can be used on mbed pin p18.
The AnalogOut Interface can be used to set the voltage on the analog output pin somwhere in the range of 0.0v to 3.3v. The 0.0v to 3.3v range of the AnalogOut can be represented in software as a normalised floating point number from 0.0 to 1.0, or directly as volts or millivolts.