Arduino Uno Objective C Serial Communication


Weeks i try to Serial send data from a Cocoa OS X App to my Arduino Uno. After weeks i found a solution, if i use the Serial File "/dev/cu.usbmodem1a1231" it WORKS! But, if use "/dev/tty.usbmodem1a1231" it dont works! I conntct Arduino Uno with USB-Cable. Does anyone know why the "/dev/cu.usbmodem1a1231" File works, but the "/dev/tty.usbmodem1a1231" File Not Workl? Thanks alot!


Sorry my endlish is not very good, i try to explain the problem again, i really hope anyone can help me.

This is my Cocoa Code:

	speed_t baudRate;
    baudRate = 9600;
    serialPortFile = @"/dev/cu.usbmodem1a1231";
    const char *bsdPath = [serialPortFile cStringUsingEncoding:NSUTF8StringEncoding];
    serialFileDescriptor = open(bsdPath, O_RDWR | O_NOCTTY | O_NONBLOCK );

-(void)sliderMoved:(id)sender {
    int val;
    val = lroundl([servoSlider floatValue]);
    write(serialFileDescriptor, (const void *)&val, 1);
    NSLog(@"%d", val);

This is the Arduino Sketch:

int ledPin = 13;
#include <Servo.h>
Servo meinServo;
int analogPin = 0;

void setup() {
        pinMode(ledPin, OUTPUT);
        digitalWrite(ledPin, LOW);

  void loop(){
       while (Serial.available()) {
        int incomingByte;
        incomingByte =;

this works. But only when i use „/dev/cu.usbmodem1a1231“.
If i try to use „/dev/tty.usbmodem1a1231“ i become it never ever to work. I can open the Port,
but Arduino never receive the Serial Signal.
Im totally confused, can please someone help me?
What is different between „/dev/cu……“ and „/dev/tty……“?
All Tutorials and User Codes i can find using the „/dev/tty……“, why it don’t works for me?

My Tech-Specs:

Arduino Uno R3 (Atmega328)
Connected with USB-Cable to
Macbook Pro with OS X 10.9
X-Code 5.01 for the Objective C App

I really erally would be happy if you can help me, i just freaking out :frowning:



Does "„/dev/tty.usbmodem1a1231" open and close the serial port? The arduino is reset when the serial port is opened/closed.

Hello, Thank you for answering! im not sure i understand what you mean. i can open /dev/tty..... then if i try to send something, arduino nothing receive.. i only close tty, when i close the my objective-c App. The same Code works if i use /dev/cu.... but it dont works with /dev/tty....

When you open the serial port, you need to wait sufficient time for the arduino to complete its reboot before sending data. That might be your problem.

oh sorry, now i understand, yes i know this and i always wait… i can wait a couple of minutes but nothing… it still not works, i actually nas waitet 5 minutes before send something, but it doesnt work :frowning: