I have the BlackWidow BLE board that I bought from back-40 and was wondering just how exactly I can have data sent from the Arduino to the iPhone. I am a beginner to Swift and so far All i know is that from the arduino side you use BLE_Shield.write("Data");
to send your input. I am unsure how to receive that input from Swift and do something with it.
I would appreciate any help! Thanks in advance!
This is actually pretty easy - you just need to look into Core Bluetooth.
Here’s a tutorial to get you started! Specifically using the BlackWidow board, and Swift!
Update:
I am using BLE_Shield.write(“X”); (Arduino) to send the letter “X” and I am using this function and it looks like it somewhat works:
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?){
let it = NSString(data: characteristic.value!, encoding: String.Encoding.utf8.rawValue)
print(it)
}
The problem now is that for some reason it is it does not display the characters correctly. Here is a couple of the prints:
What would be causing this?