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);

Committer:
RedBearLab
Date:
Wed Oct 22 05:01:13 2014 +0000
Revision:
0:4c34e71b2f6a
Child:
1:d743c358f812
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RedBearLab 0:4c34e71b2f6a 1 #ifndef _SERVO_H
RedBearLab 0:4c34e71b2f6a 2 #define _SERVO_H
RedBearLab 0:4c34e71b2f6a 3
RedBearLab 0:4c34e71b2f6a 4 #include "mbed.h"
RedBearLab 0:4c34e71b2f6a 5
RedBearLab 0:4c34e71b2f6a 6 class Servo
RedBearLab 0:4c34e71b2f6a 7 {
RedBearLab 0:4c34e71b2f6a 8 public:
RedBearLab 0:4c34e71b2f6a 9 Servo(PinName pin);
RedBearLab 0:4c34e71b2f6a 10 ~Servo(void);
RedBearLab 0:4c34e71b2f6a 11
RedBearLab 0:4c34e71b2f6a 12 void write(unsigned char degree);
RedBearLab 0:4c34e71b2f6a 13
RedBearLab 0:4c34e71b2f6a 14 private:
RedBearLab 0:4c34e71b2f6a 15 void convert(unsigned char degree);
RedBearLab 0:4c34e71b2f6a 16
RedBearLab 0:4c34e71b2f6a 17 PwmOut _servo;
RedBearLab 0:4c34e71b2f6a 18 unsigned int pulse;
RedBearLab 0:4c34e71b2f6a 19 };
RedBearLab 0:4c34e71b2f6a 20
RedBearLab 0:4c34e71b2f6a 21 #endif