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:
Fri Oct 31 14:45:22 2014 +0000
Revision:
1:d743c358f812
Parent:
0:4c34e71b2f6a
Add licence in files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RedBearLab 1:d743c358f812 1 /*
RedBearLab 1:d743c358f812 2
RedBearLab 1:d743c358f812 3 Copyright (c) 2012-2014 RedBearLab
RedBearLab 1:d743c358f812 4
RedBearLab 1:d743c358f812 5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
RedBearLab 1:d743c358f812 6 and associated documentation files (the "Software"), to deal in the Software without restriction,
RedBearLab 1:d743c358f812 7 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
RedBearLab 1:d743c358f812 8 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
RedBearLab 1:d743c358f812 9 subject to the following conditions:
RedBearLab 1:d743c358f812 10 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
RedBearLab 1:d743c358f812 11
RedBearLab 1:d743c358f812 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
RedBearLab 1:d743c358f812 13 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
RedBearLab 1:d743c358f812 14 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
RedBearLab 1:d743c358f812 15 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
RedBearLab 1:d743c358f812 16 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
RedBearLab 1:d743c358f812 17
RedBearLab 1:d743c358f812 18 */
RedBearLab 1:d743c358f812 19
RedBearLab 0:4c34e71b2f6a 20 #ifndef _SERVO_H
RedBearLab 0:4c34e71b2f6a 21 #define _SERVO_H
RedBearLab 0:4c34e71b2f6a 22
RedBearLab 0:4c34e71b2f6a 23 #include "mbed.h"
RedBearLab 0:4c34e71b2f6a 24
RedBearLab 0:4c34e71b2f6a 25 class Servo
RedBearLab 0:4c34e71b2f6a 26 {
RedBearLab 0:4c34e71b2f6a 27 public:
RedBearLab 0:4c34e71b2f6a 28 Servo(PinName pin);
RedBearLab 0:4c34e71b2f6a 29 ~Servo(void);
RedBearLab 0:4c34e71b2f6a 30
RedBearLab 0:4c34e71b2f6a 31 void write(unsigned char degree);
RedBearLab 0:4c34e71b2f6a 32
RedBearLab 0:4c34e71b2f6a 33 private:
RedBearLab 0:4c34e71b2f6a 34 void convert(unsigned char degree);
RedBearLab 0:4c34e71b2f6a 35
RedBearLab 0:4c34e71b2f6a 36 PwmOut _servo;
RedBearLab 0:4c34e71b2f6a 37 unsigned int pulse;
RedBearLab 0:4c34e71b2f6a 38 };
RedBearLab 0:4c34e71b2f6a 39
RedBearLab 0:4c34e71b2f6a 40 #endif