ADC workshop example code (DAC) IEEE TAMU
Dependencies: mbed
Fork of mbed_DAC by
Revision 0:0c6c66dabc1c, committed 2015-04-03
- Comitter:
- matthewrdestefano
- Date:
- Fri Apr 03 21:09:53 2015 +0000
- Commit message:
- DAC example code
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
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 + } +} + + +
diff -r 000000000000 -r 0c6c66dabc1c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Apr 03 21:09:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file