I2C ADC to SPI DAC example
Dependencies: MCP3221 MCP4822lib mbed
Fork of MCP3221_TEST by
Revision 1:38e8128d989b, committed 2015-03-26
- Comitter:
- janekm
- Date:
- Thu Mar 26 13:44:57 2015 +0000
- Parent:
- 0:88f03a5d0ca0
- Child:
- 2:b28c99e359f6
- Commit message:
- initial version
Changed in this revision
| MCP4822lib.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MCP4822lib.lib Thu Mar 26 13:44:57 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/NickRyder/code/MCP4822lib/#7484c0fe6f4d
--- a/main.cpp Wed Oct 31 22:16:00 2012 +0000
+++ b/main.cpp Thu Mar 26 13:44:57 2015 +0000
@@ -1,20 +1,23 @@
#include "mbed.h"
#include "MCP3221.h"
+#include "MCP4822.h"
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX); // tx, rx
-AnalogIn ain(p20);
MCP3221 adc(p9, p10, 5.0); //sda, scl, supplyVoltage
+MCP4822 dac (p11, p12, p13, p14);
int main() {
-
+ float reading;
wait(1);
while (1) {
pc.printf("ain: %f :: ", ain.read()*3.3);
- pc.printf("adc: %f \r\n", adc.read());
+ reading = adc.read();
+ pc.printf("adc: %f \r\n", reading);
+ dac.setA(reading);
myled=!myled;
