Send data from the board to node red

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
div1104
Date:
Sat Jan 23 16:58:49 2021 +0000
Commit message:
Node red

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 3f47fd49ccff main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 23 16:58:49 2021 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+AnalogIn ain(A0);
+AnalogIn ain1(A1);
+AnalogIn ain2(A2);
+Serial pc(USBTX,USBRX);
+
+int main() 
+{
+    float adc_value1,adc_value2,adc_value3;
+    char ch;
+    while(1) 
+    {   
+        
+        if(pc.readable())
+        {
+       ch=pc.getc();
+        }
+        
+        switch(ch)
+        { 
+        case 'p':adc_value1=3.3*ain.read();
+        pc.printf("pot value = %f \n",adc_value1);
+        wait(0.5);
+        break;
+        case 'l':adc_value2=3.3*ain1.read();
+        pc.printf("ldr value = %f \n",adc_value2);
+        wait(0.5);
+        break;
+        case 't':adc_value3=3.3*ain2.read();
+        pc.printf("tempsenor value = %f \n",adc_value3);
+        wait(0.5);
+        break;
+        default:pc.printf("wrong");
+        wait(0.5);
+        break;
+        }
+    }
+}
diff -r 000000000000 -r 3f47fd49ccff mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 23 16:58:49 2021 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/64910690c574
\ No newline at end of file