#include <ble_mini.h>
#include <Servo.h>
#define SERVO_PIN 7
Servo myservo;
void setup()
{
BLEMini_begin(57600);
myservo.attach(SERVO_PIN);
}
void loop()
{
// If data is ready
while ( BLEMini_available() == 3 )
{
// read out command and data
byte data0 = BLEMini_read();
byte data1 = BLEMini_read();
byte data2 = BLEMini_read();
if (data0 == 0x03) // Command is to control Servo pin
{
myservo.write(data1);
}
else if (data0 == 0x04) // Command is to reset
{
myservo.write(0);
}
}
}