我正在尝试使用 this tutorial 提供的代码示例将字符“b”写入 iPhone 的串行端口,但我没有得到想要的结果。当我使用 this link 提供的串行控制台应用程序时它似乎正在向 Arduino 发送字母/字符“b”,因为我的灯开始闪烁。
我为尝试发送“b”字符的应用构建的方法如下所示,
- (IBAction)blinkFlow_A_LED:(id)sender {
// method to blink the Flow_A LED on the kegboard-mini Arduino sheild.
NSLog(@"blink Flow_A btn pressed");
NSLog(@"hello kyle");
// open serial port / interface
[serial open:B2400];
if(serial.isOpened)
{
NSLog(@"Serial Port Opened");
}
else NSLog(@"Serial Port Closed");
// print serial debugging messages
serial.debug = true;
// send serial data (tx)
[serial write:text];
// print message sent
NSLog(@"the command sent was:%@",text);
}
最佳答案
您在哪里定义“文本”?文本应该是 NSString。
例如:
[serial write:@"hello world"];
关于iphone - 串行写入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290848/