202B voltage sensing

Dependencies:   SLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
davidur
Date:
Thu Jun 11 21:13:09 2015 +0000
Commit message:
Sensing voltage

Changed in this revision

SLCD.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
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/SLCD.lib	Thu Jun 11 21:13:09 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 11 21:13:09 2015 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "SLCD.h"
+
+SLCD slcd;
+AnalogOut DAC(PTE30);
+Serial pc(USBTX, USBRX);
+AnalogIn Ain1(PTB0);
+//AnalogIn Ain2(PTB1);
+
+int main() 
+{
+    float ADCdata1;
+    //float ADCdata2;
+    float high_out = 0.999;
+    float low_out = 0.0;
+    float current_out = low_out;
+    slcd.clear();
+    int state = 0;
+    while (1) {
+        ADCdata1=Ain1*3.3;
+        //ADCdata2=Ain2*3.3;
+        pc.printf("recv_in_1 %f \n\r",ADCdata1);
+        //pc.printf("recv_in_2 %f \n\r",ADCdata2);
+        pc.printf("state %i \n\r",state);
+        pc.printf("output %f \n\r", current_out);        
+        wait (0.2);
+        //3.8 -> 0.95
+        if (state == 0 && ADCdata1 < 0.95)
+        {current_out = high_out;
+            state = 1;}                
+        //7.5 -> 1.785
+        //7 -> 1.75
+        if (state == 1 && ADCdata1 > 1.785)
+        {current_out = low_out;
+            state = 0;}            
+        DAC = current_out;
+        slcd.printf("%1.3f", ADCdata1);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 11 21:13:09 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file