test00

Dependencies:   MCP4725 mbed

Fork of test01 by Four Squared

Revision:
0:77006df50c28
Child:
1:c5360811157c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 02 15:41:23 2016 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "mcp4725.h"
+
+/**
+ * A test program for the MCP4725 DAC Library. This Test Application requires the following:
+ *  * An MCP4725 connected to the I2C bus of the mbed LPC1768.
+ *  * The analog out of the MCP1768 connected to Pin15 (analog in) of the mbed LPC1768.
+ *  
+ *
+ * This is a stripped down version of the MCP4725_Library_Test found online, and should make the necessary commands more clear.
+ * Last Edited: 12/24/13, Tim Brubaker
+ *
+ */
+
+DigitalOut testLed(LED1);
+Serial pc(USBTX, USBRX);
+AnalogIn analogIn(p15);
+
+// Class instantiation (similar to Serial pc(USBTX, USBRX) in function)
+MCP4725 bacon(p9, p10, MCP4725::Fast400kHz, 0);
+      
+
+int main()
+{
+    // Print to terminal
+    pc.printf("Ready.......FIGHT!\r\n");
+ 
+    while(1) {
+        testLed = 1;
+        wait(0.5);
+        // Write to DAC register (not EEPROM). Documentation in library files.
+        bacon.write(MCP4725::Normal, (0xFFF * (1.0/3.3) ), false);
+        testLed = 0;
+        wait(0.5);
+        // Print ADC measurement to terminal. Scale factor of 3.3 needed for internal ADC.
+        pc.printf("Value is %f V \r\n",analogIn.read()*3.3);
+    }
+}
\ No newline at end of file