bluetooth_0110

Dependencies:   Serial_HL mbed

Files at this revision

API Documentation at this revision

Comitter:
andreashatzl
Date:
Thu Oct 01 18:18:46 2015 +0000
Commit message:
bluetoothansteuerung motor

Changed in this revision

Serial_HL.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 11047e265142 Serial_HL.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Serial_HL.lib	Thu Oct 01 18:18:46 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hollegha2/code/Serial_HL/#b958bdf108cf
diff -r 000000000000 -r 11047e265142 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 01 18:18:46 2015 +0000
@@ -0,0 +1,75 @@
+
+#include "mbed.h"
+#include "Serial_HL.h"
+
+// Testprogramm um zu sehen ob die RGB-Led richtig verlötet
+// ist und ob sie sich auch dimmen lässt
+
+SerialBLK pc(USBTX, USBRX);
+SvProtocol ua0(&pc);
+
+PwmOut servo1(p21),servo2(p22),servo3(p23);
+SerialBLK blue(p9, p10);
+int16_t stickVal1,stickVal2,stickVal3;
+
+void CommandHandler();
+
+int main()
+{
+    servo1.period_ms(20);
+    servo2.period_ms(20);
+    servo3.period_ms(20);
+    
+    pc.format(8,SerialBLK::None,1);pc.baud(115200);blue.baud(115200);
+    ua0.SvMessage("ServoTest");
+    
+    Timer stw; stw.start();
+    while(1)
+    {
+        CommandHandler();
+        if((stw.read_ms()>100))
+        {
+            stw.reset();
+            if(ua0.acqON)
+            {
+             ua0.SvMessage(stickVal1);
+             ua0.WriteSvI16(1, stickVal1);
+             ua0.WriteSvI16(2, stickVal2);
+             ua0.WriteSvI16(3, stickVal3);   
+                }
+            }
+        }
+    
+    return 1;
+}
+
+
+void CommandHandler()
+{
+    uint8_t cmd;
+   
+
+    // Fragen ob überhaupt etwas im RX-Reg steht
+    if( !blue.IsDataAvail() )
+        return;
+
+    // wenn etwas im RX-Reg steht
+    // Kommando lesen
+    cmd = ua0.GetCommand();
+
+    if( cmd==2 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal1 = ua0.ReadI16();
+        servo1.pulsewidth_us(1000+stickVal1);
+    }
+    if( cmd==3 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal2 = ua0.ReadI16();
+        servo2.pulsewidth_us(1000+stickVal2);
+    }
+    if( cmd==4 ) {
+        // cmd2 hat 2 int16 Parameter
+        stickVal3 = ua0.ReadI16();
+        servo3.pulsewidth_us(1000+stickVal3);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 11047e265142 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 01 18:18:46 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa
\ No newline at end of file