![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Revision 4:315948ed8c64, committed 2016-05-17
- Comitter:
- FranKP2138
- Date:
- Tue May 17 17:29:01 2016 +0000
- Parent:
- 3:f530ca03e014
- Commit message:
- Change control on Led and Sensor->analogIn
Changed in this revision
--- a/BLE_API.lib Thu Jan 07 02:43:53 2016 +0000 +++ b/BLE_API.lib Tue May 17 17:29:01 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#bfc5b9b6ecf5 +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21
--- 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; }
--- a/mbed.bld Thu Jan 07 02:43:53 2016 +0000 +++ b/mbed.bld Tue May 17 17:29:01 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e \ No newline at end of file
--- a/nRF51822.lib Thu Jan 07 02:43:53 2016 +0000 +++ b/nRF51822.lib Tue May 17 17:29:01 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#3cc0718d98d0 +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc