ADC workshop example code (DAC) IEEE TAMU
Dependencies: mbed
Fork of mbed_DAC by
Diff: main.cpp
- Revision:
- 0:0c6c66dabc1c
diff -r 000000000000 -r 0c6c66dabc1c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 03 21:09:53 2015 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +AnalogIn voltage(PTB0); // set the analog input to pin PTB0 +AnalogOut DACout(PTE30); // set Analog output pin to PTE30 +int main(void) { + + PwmOut led(LED_RED); // set green LED as PWM output + while (true) // infinite loop + { + DACout = DACout + 0.01; // increase the analog output + if(DACout >= 1.0) // if we reach 100% output + { + DACout = 0; // go back to the begining + } + led = 1.0 - voltage.read(); // update the LED brightness with ADC data + wait(0.02); // wait 1/50th of a second + } +} + + +