2013-04-30 76 views
1

我正嘗試使用從this tutorial提供的代碼示例在iPhone上的串行端口寫入字符「b」,但我沒有得到期望的結果。當我使用從this link提供的串行控制檯應用程序時,它似乎是將字母/字符「b」發送給Arduino,因爲我的指示燈開始閃爍。串行寫入無法正常工作

我的,我嘗試發送「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); 
} 

回答

2

你在哪裏定義「文」?文本應該是NSString。

如:

[serial write:@"hello world"];