Lab2 code

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
m0t0
Date:
Wed Jan 31 00:44:59 2018 +0000
Commit message:
LAB2

Changed in this revision

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
diff -r 000000000000 -r 7cab971d062d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 31 00:44:59 2018 +0000
@@ -0,0 +1,60 @@
+
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+#if !DEVICE_ANALOGOUT
+#error You cannot use this example as the AnalogOut is not supported on this device.
+#else
+AnalogOut my_output(PA_4);
+#endif
+
+#define PI        (3.141592653589793238462)
+#define AMPLITUDE (1.0)    // x * 3.3V
+#define PHASE     (PI * 1) // 2*pi is one period
+#define RANGE     (0x7FFF)
+#define OFFSET    (0x7FFF)
+
+// Configuration for sinewave output
+#define BUFFER_SIZE (360)
+
+uint16_t buffer[BUFFER_SIZE];
+
+void DCout(double Vout){
+    double HEXval;
+    HEXval = Vout * 19763.0;
+    my_output.write_u16(HEXval);
+}
+
+char s [30];
+
+void scan(){
+
+int i = 0;
+
+
+while(i<30){
+    s[i] = pc.getc();
+    if(s[i] != 0X0d){
+        pc.putc(s[i]);
+        i++;
+        }
+        else{
+            break;
+            }
+        }
+
+DCout(atof(s));
+
+
+scan();
+
+
+}
+
+
+int main() {
+
+    char p1 [] = "Enter Voltage";
+    pc.printf("%s\n", p1);
+    scan();
+}
+
diff -r 000000000000 -r 7cab971d062d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jan 31 00:44:59 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file