AndroidのBLEラジコンプロポアプリ「BLEPropo」と接続し、RCサーボとDCモータを制御するプログラムです。 mbed HRM1017で動作を確認しています。 BLEPropo → https://github.com/lipoyang/BLEPropo

Dependencies:   BLE_API mbed

Fork of BLE_RCBController2 by Junichi Katsu

BLEを使ったAndroid用ラジコンプロポアプリ「BLEPropo」に対応するmbed HRM1017用ファームウェアです。
BLEPropoは、GitHubにて公開中。
https://github.com/lipoyang/BLEPropo
/media/uploads/lipoyang/blepropo_ui.png
ラジコンは、mbed HRM1017とRCサーボやDCモータを組み合わせて作ります。
/media/uploads/lipoyang/ble_wiring.png

Files at this revision

API Documentation at this revision

Comitter:
lipoyang
Date:
Sat Mar 14 11:51:38 2015 +0000
Parent:
6:63787b19ec1e
Commit message:
- adjust servo center position

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Feb 09 12:42:56 2015 +0000
+++ b/main.cpp	Sat Mar 14 11:51:38 2015 +0000
@@ -19,16 +19,6 @@
  * limitations under the License.
  */
 
-/*
- * Library Dependencies:
- * - BLE_API (revision 111)
- * - HRM1017
- *   - HRM1017/projectconfig.h
- *     connection interval constants are modified. (No need?)
- *     CFG_GAP_CONNECTION_MIN_INTERVAL_MS 30 
- *     CFG_GAP_CONNECTION_MAX_INTERVAL_MS 50
- */
-
 #include "mbed.h"
 #include "BLEDevice.h"
 
@@ -103,17 +93,27 @@
         tb6612_pwma = 1;
         tb6612_ain1 = 0;
         tb6612_ain2 = 0;
-//        // break
-//        tb6612_pwma = 1;
-//        tb6612_ain1 = 1;
-//        tb6612_ain2 = 1;
     }
 }
 
+void motor_break()
+{
+    // break
+    tb6612_pwma = 1;
+    tb6612_ain1 = 1;
+    tb6612_ain2 = 1;
+}
+
+// you must adjust center position
+#define RL_ADJ      (0)
+#define RL_CENTER   (1500)
+#define RL_RANGE    (500.0)
+
 // RC servo
-void servo (float deg)
+// rl : -1.0 ? 1.0
+void servo (float rl)
 {
-    servo_pwm.pulsewidth_us(1500 + (int)(500.0 * deg));
+    servo_pwm.pulsewidth_us(RL_CENTER + RL_ADJ + (int)(RL_RANGE * rl));
 }
 
 // BLE onConnection handler
@@ -159,7 +159,7 @@
 #endif
 	// initialize servo & motor
     servo_pwm.period_ms(20);
-    servo(0.5);
+    servo(0);
     motor(0);
 	
 	// initialize BLE