lab2-2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wonner163
Date:
Thu Nov 23 14:49:32 2017 +0000
Commit message:
lab2-2; ;

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 fd737e4b3c32 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 23 14:49:32 2017 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+ 
+AnalogIn analog_value(A1); //object  คือ analog_value
+ 
+BusOut myleds(D2,D3,D4,D5);
+BusOut myleda(D6,D7,D8,D9);
+Serial pc(D1, D0);
+
+ 
+int main() {
+    float meas;
+    int decimal; //หลักทศนิยม
+    int unit; //หลักหน่วย
+
+    while(1) {
+        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) แปลงแรงดันจาก 0-3.3 เป็นดิจิตอล 0.0-1.0
+        //meas = analog_value.read();
+        meas = meas * 33; // Change the value to be in the 0 to 3300 range
+        decimal = meas;
+        unit = meas;
+        decimal = decimal % 10;
+        unit = unit-decimal;
+       
+        
+        unit = unit % 100;
+        unit = unit / 10;
+        myleds = decimal;
+        myleda = unit;
+        pc.printf("%d",unit); 
+        pc.printf("%d",decimal);
+        pc.printf("\n");
+        wait(0.1);
+        
+    }
+}
diff -r 000000000000 -r fd737e4b3c32 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 23 14:49:32 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file