Thank for your help.
Since the Arduino 101 only can act as a Slave i have two options
- Control every thing with my iPhone 5.
I was able to write some code, so the Motor will turn on if i connect to the Arduino. this is fine. But i also would like to set the speed of the Motor with my iPhone. I did not manage to do this until now. When i connect to the Arduino with the iPhone i can only send some 0x.... commands and do not know what his means?!?
How can i send some values to the Arduino with an app? Do you know some good apps? How do i have to write the code?
------- With this i would like to define the Services and Characteristics:------
BLEPeripheral blePeripheral; // create peripheral instance
// Neuer Service für die Kommandos des anderen Arduinos
BLEService firstService("19B10000-E8F2-537E-4F6C-D104768A1214"); // create service
BLECharCharacteristic commands("19B1001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite | BLENotify); // create switch characteristic and allow remote device to read and write
BLEIntCharacteristic v("19B10002-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite | BLENotify); // Geschwindigkeit
------- And these are the Callbacks i would like to make: ----------
// assign event handlers for connected, disconnected to peripheral
blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler); // je zwei CALLBACKS
blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
// assign event handlers for characteristic
commands.setEventHandler(BLEWritten, SteuerungDerGeschwindigkeit);
------- and the Callbacks defined--------
void blePeripheralConnectHandler(BLECentral& central) {
// central connected event handler
Serial.print("Connected event, central: ");
Serial.println(central.address());
firstMotor->setSpeed(40);
firstMotor->run(FORWARD);
}
void blePeripheralDisconnectHandler(BLECentral& central) {
// central disconnected event handler
Serial.print("Disconnected event, central: ");
Serial.println(central.address());
firstMotor->run(RELEASE);
fitstMotor->setSpeed(0);
}
void SteuerungDerGeschwindigkeit(BLECentral& central, BLECharacteristic& characteristic) {
// central wrote new value to characteristic, update Speed
Serial.print("Characteristic event, written: ");
int i;
if (commands.value() == 0) {
Serial.println("Start the Motor mit der gegebenen Geschwindigkeit");
firstMotor->run(FORWARD);
for (i=0; i<v.value(); i++) {
firstMotor->setSpeed(i);
delay(50);
}
} else {
if (commands.value() == 1) {
Serial.println("Stoppen");
for (i=v.value(); i>0; i--) {
firstMotor->setSpeed(i);
delay(50);
}
}
}
... but a I sad, i can connect to the Arduino with a app, but I can not write values for "commands" and "v"
Alternatively i can also connect with my Mac. Do you know a good software to send some commands?
- The other option to make the whole communication with a Seeed BLE Shield v1.1 that i found.
I have a example from http://www.seeedstudio.com/wiki/Seeed_BLE_Shield_v1 but this did not work!!
Is there a special baud rate i have to chose? Or does the Shield can not read the AT commands?
Thanks for your Help.