ADC workshop example code (DAC) IEEE TAMU

Dependencies:   mbed

Fork of mbed_DAC by Matthew DeStefano

Files at this revision

API Documentation at this revision

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
--- /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
+    }
+}
+
+
+
--- /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