Bluetooth enabled control of a BLDC via the Allegro MicroSystems A4960.

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_LED by Bluetooth Low Energy

Revision:
11:4251b62991ac
Parent:
10:af76616e4d75
diff -r af76616e4d75 -r 4251b62991ac main.cpp
--- a/main.cpp	Tue Jan 12 10:34:34 2016 +0000
+++ b/main.cpp	Tue May 16 19:31:49 2017 +0000
@@ -17,9 +17,11 @@
 #include "mbed.h"
 #include "ble/BLE.h"
 #include "LEDService.h"
+#include "a4960.h"
 
-DigitalOut alivenessLED(LED1, 0);
-DigitalOut actuatedLED(LED2, 0);
+DigitalOut alivenessLED(P0_6, 0);
+DigitalOut actuatedLED(P0_7, 0);
+a4960 motor;
 
 const static char     DEVICE_NAME[] = "LED";
 static const uint16_t uuid16_list[] = {LEDService::LED_SERVICE_UUID};
@@ -47,6 +49,14 @@
 void onDataWrittenCallback(const GattWriteCallbackParams *params) {
     if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) {
         actuatedLED = *(params->data);
+        if (*(params->data))
+        {
+            motor.write_run();
+        }
+        else
+        {
+            motor.write_brake();
+        }
     }
 }