test00

Dependencies:   MCP4725 mbed

Fork of test01 by Four Squared

Committer:
xWhitfordx
Date:
Wed Nov 02 15:41:23 2016 +0000
Revision:
0:77006df50c28
Child:
1:c5360811157c
test01

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xWhitfordx 0:77006df50c28 1 #include "mbed.h"
xWhitfordx 0:77006df50c28 2 #include "mcp4725.h"
xWhitfordx 0:77006df50c28 3
xWhitfordx 0:77006df50c28 4 /**
xWhitfordx 0:77006df50c28 5 * A test program for the MCP4725 DAC Library. This Test Application requires the following:
xWhitfordx 0:77006df50c28 6 * * An MCP4725 connected to the I2C bus of the mbed LPC1768.
xWhitfordx 0:77006df50c28 7 * * The analog out of the MCP1768 connected to Pin15 (analog in) of the mbed LPC1768.
xWhitfordx 0:77006df50c28 8 *
xWhitfordx 0:77006df50c28 9 *
xWhitfordx 0:77006df50c28 10 * This is a stripped down version of the MCP4725_Library_Test found online, and should make the necessary commands more clear.
xWhitfordx 0:77006df50c28 11 * Last Edited: 12/24/13, Tim Brubaker
xWhitfordx 0:77006df50c28 12 *
xWhitfordx 0:77006df50c28 13 */
xWhitfordx 0:77006df50c28 14
xWhitfordx 0:77006df50c28 15 DigitalOut testLed(LED1);
xWhitfordx 0:77006df50c28 16 Serial pc(USBTX, USBRX);
xWhitfordx 0:77006df50c28 17 AnalogIn analogIn(p15);
xWhitfordx 0:77006df50c28 18
xWhitfordx 0:77006df50c28 19 // Class instantiation (similar to Serial pc(USBTX, USBRX) in function)
xWhitfordx 0:77006df50c28 20 MCP4725 bacon(p9, p10, MCP4725::Fast400kHz, 0);
xWhitfordx 0:77006df50c28 21
xWhitfordx 0:77006df50c28 22
xWhitfordx 0:77006df50c28 23 int main()
xWhitfordx 0:77006df50c28 24 {
xWhitfordx 0:77006df50c28 25 // Print to terminal
xWhitfordx 0:77006df50c28 26 pc.printf("Ready.......FIGHT!\r\n");
xWhitfordx 0:77006df50c28 27
xWhitfordx 0:77006df50c28 28 while(1) {
xWhitfordx 0:77006df50c28 29 testLed = 1;
xWhitfordx 0:77006df50c28 30 wait(0.5);
xWhitfordx 0:77006df50c28 31 // Write to DAC register (not EEPROM). Documentation in library files.
xWhitfordx 0:77006df50c28 32 bacon.write(MCP4725::Normal, (0xFFF * (1.0/3.3) ), false);
xWhitfordx 0:77006df50c28 33 testLed = 0;
xWhitfordx 0:77006df50c28 34 wait(0.5);
xWhitfordx 0:77006df50c28 35 // Print ADC measurement to terminal. Scale factor of 3.3 needed for internal ADC.
xWhitfordx 0:77006df50c28 36 pc.printf("Value is %f V \r\n",analogIn.read()*3.3);
xWhitfordx 0:77006df50c28 37 }
xWhitfordx 0:77006df50c28 38 }