Serial With Mode Serial

Dependencies:   DHT11 MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
DSPMARCO
Date:
Thu Dec 29 04:18:13 2016 +0000
Commit message:
Serial With Mode Serial

Changed in this revision

DHT11.lib Show annotated file Show diff for this revision Revisions of this file
MODSERIAL.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/DHT11.lib	Thu Dec 29 04:18:13 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/fossum_13/code/DHT11/#5da6f6de3e42
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Thu Dec 29 04:18:13 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MODSERIAL/#4737f8a5b018
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 29 04:18:13 2016 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+#include "Dht11.h"
+#include "MODSERIAL.h"
+MODSERIAL usbser(USBTX, USBRX); // tx, rx
+MODSERIAL devser(PTE22, PTE23); // tx, rx
+//Serial usbser(USBTX, USBRX); // tx, rx
+//Serial devser(PTE22, PTE23); // tx, rx
+DigitalOut R(LED1);
+DigitalOut G(LED2);
+DigitalOut B(LED3);
+
+Dht11 mydht11(D9);
+
+int main(void) 
+{
+    char X;
+    float t,h;
+
+    usbser.baud(9600);
+    devser.baud(9600);
+    R=1;
+    G=1;
+    B=1;
+    
+    while (true) 
+     {
+        mydht11.read(); // Read DHT11 sensor
+        t = mydht11.getCelsius(); // get Temperature in C
+        h = mydht11.getHumidity(); // get Humidity in %
+        printf("Temperature is : %0.2f C\r\n",t);
+        wait(0.5);
+        
+        if(usbser.readable())
+        {
+            devser.putc(usbser.getc());
+        }
+        
+        if(devser.readable())
+        {
+            X=devser.getc();
+            usbser.putc(X);
+            printf("\r\n");
+            if(X == 'R')
+            {
+                G=1;
+                B=1;
+                R=0;            
+            }
+            else if(X == 'G')
+            {
+                R=1;
+                B=1;
+                G=0;
+            }
+            else if(X == 'B')
+            {
+                R=1;
+                G=1;
+                B=0;
+            }
+            else
+            {
+                R=0;
+                G=0;
+                B=0;
+            }
+        }
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 29 04:18:13 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9baf128c2fab
\ No newline at end of file