Adam Abate
/
SPI_MCP3002
Lab 10/24/18 and 10/30/18
Fork of SPI_MCP3002 by
Diff: main.cpp
- Revision:
- 1:178a0f92d2ab
- Parent:
- 0:08026df17556
--- a/main.cpp Mon Oct 02 01:52:48 2017 +0000 +++ b/main.cpp Tue Oct 30 22:11:27 2018 +0000 @@ -19,6 +19,7 @@ spi.format(8,0); spi.frequency(10000); int data1, data2, mask, channel; + aout = 0.0; // Supply voltage is nominally 3.3V float VCC=3.3, vIn; while(1) { @@ -30,8 +31,9 @@ } cs = 0; data1 = spi.write(mask); + cs = 1; data2 = spi.write(0); - cs = 1; + //cs = 1; // Format for MSB set data1 &= 0x03; // keep only three bits data2 |= data1 << 8 ; // shift and add to LSB @@ -39,6 +41,9 @@ vIn = VCC*data2/1000.; pc.printf("Channel %i Voltage is %f \r\n",channel,vIn); } - wait(1); + aout = aout + 0.1; + float volt = aout; + pc.printf("Analog output of mbed is %f \r\n", volt); + //wait(1); } }