SimpleControls works with the BLEController iOS/Android App. The mbed's pin can acts as DIGITAL_IN, DIGITAL_OUT, PWM, SERVO, ANALOG_IN. The sketch is to show you how to control the pin as one of the abilities.

Dependencies:   BLE_API mbed nRF51822

Fork of BLENano_SimpleControls by RedBearLab

Revision:
4:315948ed8c64
Parent:
3:f530ca03e014
--- a/main.cpp	Thu Jan 07 02:43:53 2016 +0000
+++ b/main.cpp	Tue May 17 17:29:01 2016 +0000
@@ -1,5 +1,4 @@
 /*
-
 Copyright (c) 2012-2014 RedBearLab
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
@@ -16,31 +15,36 @@
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 */
-
+//UnComment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 #include "mbed.h"
 #include "ble/BLE.h"
-#include "Servo.h"
+//#include "Servo.h"
 
 
 #define BLE_UUID_TXRX_SERVICE            0x0000 /**< The UUID of the Nordic UART Service. */
 #define BLE_UUID_TX_CHARACTERISTIC       0x0002 /**< The UUID of the TX Characteristic. */
 #define BLE_UUIDS_RX_CHARACTERISTIC      0x0003 /**< The UUID of the RX Characteristic. */
 
-#define TXRX_BUF_LEN                     20
+#define TXRX_BUF_LEN                     20 // può anche essere più corta ho tolto dei valori da trasmettere e leggere
+// Devo add level Battery
+//cambiare P0_19 to P0_10 attivato da Central indica connessione attiva 
+#define DIGITAL_OUT_PIN                  P0_19       //TXD
+//Posso anche eliminare 
+#define DIGITAL_IN_PIN                   P0_10      //CTS
+//Posso anche eliminare
+//#define PWM_PIN                          P0_11      //RXD
 
-#define DIGITAL_OUT_PIN                  P0_9       //TXD
-#define DIGITAL_IN_PIN                   P0_10      //CTS
-#define PWM_PIN                          P0_11      //RXD
-#define SERVO_PIN                        P0_8       //RTS
+//#define SERVO_PIN                        P0_8       //RTS
+//qui posso collegare il sensore
 #define ANALOG_IN_PIN                    P0_4       //P04
 
 BLE             ble;
 
 DigitalOut      LED_SET(DIGITAL_OUT_PIN);
 DigitalIn       BUTTON(DIGITAL_IN_PIN);
-PwmOut          PWM(PWM_PIN);
+//PwmOut          PWM(PWM_PIN);
 AnalogIn        ANALOG(ANALOG_IN_PIN);
-Servo           MYSERVO(SERVO_PIN);
+//Servo           MYSERVO(SERVO_PIN);
 
 //Serial pc(USBTX, USBRX);
 
@@ -92,34 +96,34 @@
         //for(index=0; index<bytesRead; index++)
             //pc.putc(buf[index]);
             
-        if(buf[0] == 0x01)
+        if(buf[0] == 0x01)  // accende il led viene attivato da Central
         {
             if(buf[1] == 0x01)
                 LED_SET = 1;
             else
                 LED_SET = 0;    
         }
-        else if(buf[0] == 0xA0)
+        else if(buf[0] == 0xA0) // attiva analogIn Se valida Connection Viene Attivata da Central
         {
             if(buf[1] == 0x01)
                 analog_enabled = 1;
             else
                 analog_enabled = 0;
         }
-        else if(buf[0] == 0x02)
+       /* else if(buf[0] == 0x02) // attiva PWM
         {
             float value = (float)buf[1]/255;
             PWM = value;
-        }
-        else if(buf[0] == 0x03)
+        }*/
+        /*else if(buf[0] == 0x03) // Attiva Servo
         {
             MYSERVO.write(buf[1]);
-        }
-        else if(buf[0] == 0x04)
+        }*/
+        else if(buf[0] == 0x04) // Disattiva Tutto
         {
             analog_enabled = 0;
-            PWM = 0;
-            MYSERVO.write(0);
+            //PWM = 0;
+            //MYSERVO.write(0);
             LED_SET = 0;
             old_state = 0;    
         }