This program demonstrate how to apply BLE_nRF8001 library on mbed platform working with RedBearLab BLE Shield v2.1 or above.

Dependencies:   BLE_nRF8001 mbed

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. Note that not every pin can own all of the abilities. You can change the following macro to specify which pin to be controlled.

DigitalInOut DIGITAL_OUT_PIN( PTD4 );

DigitalInOut DIGITAL_IN_PIN( PTA12 );

PwmOut pwm( PTA4 );

Servo myservo( PTA13 );

AnalogIn analog( PTB0 );

The application will report the state of DIGITAL_IN_PIN and ANALOG_IN_PIN to App. The App can control the state of DIGITAL_OUT_PIN / PWM_PIN / SERVO_PIN.

You have to change the belowing constructs manually corresponding to the platform you are using.

SPI spi(PTD2, PTD3, PTD1);

DigitalInOut BLE_RDY(PTA12);

DigitalInOut BLE_REQ(PTA2);

Revision:
0:4c34e71b2f6a
Child:
1:d743c358f812
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.h	Wed Oct 22 05:01:13 2014 +0000
@@ -0,0 +1,21 @@
+#ifndef _SERVO_H
+#define _SERVO_H
+
+#include "mbed.h"
+
+class Servo
+{
+public:
+    Servo(PinName pin);
+    ~Servo(void);
+    
+    void write(unsigned char degree);
+
+private:
+    void convert(unsigned char degree);
+    
+    PwmOut _servo;
+    unsigned int pulse;
+};
+
+#endif
\ No newline at end of file