api / mbed / trunk / AnalogOut
AnalogOut
class AnalogOut : public Base
An analog output, used for setting the voltage on a pin
Example
// Make a sawtooth output
#include "mbed.h"
AnalogOut tri(p18);
int main() {
while(1) {
tri = tri + 0.01;
wait_us(1);
if(tri == 1) {
tri = 0;
}
}
}| 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() |
write
void write( float value )
Set the output voltage, specified as a percentage (float)
Variables
| percent | A floating-point value representing the output voltage, specified as a percentage. The value should lie between 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%). Values outside this range will be saturated to 0.0f or 1.0f. |
read
float read()
Return the current output voltage setting, measured as a percentage (float)
Variables
| returns | A floating-point value representing the current voltage being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%). |
Note
This value may not match exactly the value set by a previous write.
operator=
AnalogOut& operator= ( float percent )
An operator shorthand for write()
operator float()
operator float()
An operator shorthand for read()
An analog output, used for setting the voltage on a pin
class AnalogOut : public Base
Create an AnalogOut connected to the specified pin
AnalogOut( PinName pin, const char * name = NULL )
Set the output voltage, specified as a percentage (float)
void write( float value )
Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
void write_u16( unsigned short value )
Return the current output voltage setting, measured as a percentage (float)
float read()
An operator shorthand for write()
AnalogOut& operator= ( float percent )
An operator shorthand for read()
operator float()
