Fei Wu / Mbed 2 deprecated ECE4180-IoT_Bluetooth_Fan_Controller

Dependencies:   Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
wufeiok
Date:
Mon Mar 13 23:43:10 2017 +0000
Commit message:
Bluetooth Fan Controller;

Changed in this revision

Motor.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
diff -r 000000000000 -r 84c73f8a4a96 Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Mon Mar 13 23:43:10 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 84c73f8a4a96 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 13 23:43:10 2017 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "Motor.h"
+RawSerial  pc(USBTX, USBRX);
+RawSerial  dev(p13, p14);
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+AnalogIn   temp(p15);
+
+Motor m(p23, p6, p5);
+
+float _temp; 
+float _speed = 0;
+void dev_recv()
+{
+    led1 = !led1;
+    while(dev.readable()) {
+        char mode = dev.getc();
+        if (mode == 'T') {
+            _temp = temp;
+            _temp = 38.0-27.5*_temp;
+            dev.printf("%f\n",_temp);
+ 
+        }
+        if (mode=='V') {
+            char type = dev.getc();
+            if(type=='?') {
+                dev.printf("%f\n",_speed);
+            }  
+            if(type=='+') {
+                if (_speed < 1.0) {
+                    _speed= _speed + 0.1;
+                }
+                m.speed(_speed);
+                dev.printf("New Speed %f\n",_speed);
+            } 
+            if(type=='-') {
+                if (_speed >= 0.1) _speed-= 0.1;
+                m.speed(_speed);
+                dev.printf("New Speed %f\n",_speed);
+            }
+        }
+        
+    }
+}
+
+void pc_recv()
+{
+    led4 = !led4;
+    while(pc.readable()) {
+        dev.putc(pc.getc());
+    }
+}
+
+int main()
+{
+    pc.baud(9600);
+    dev.baud(9600);
+
+    pc.attach(&pc_recv, Serial::RxIrq);
+    dev.attach(&dev_recv, Serial::RxIrq);
+
+    while(1) {
+        sleep();
+    }
+}
diff -r 000000000000 -r 84c73f8a4a96 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 13 23:43:10 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file