How to use Xcode output signal to control LED light?

Discussion in 'Mac Programming' started by Toptwo, May 10, 2012.

  1. macrumors newbie

    Joined:
    May 10, 2012
    Location:
    taiwan
    #1
  2. ytk
    macrumors regular

    Joined:
    Jul 8, 2010
    #2
    You'd need some sort of hardware interface. If you just want to generate a high/low signal, you can simply use a USB to serial adaptor, and set the DTR and RTS lines as needed. You could also read signals over the CD, DSR, CTS, and RI lines. This would give you 2 lines out and 4 in. I'm not sure how exactly to address the serial port in ObjC/Cocoa, but I'm certain there's a way, either via the built-in serial library or some third party library.

    If you're looking to do something more complicated, or require more control lines, you might want to look into using an Arduino or similar microcontroller as your hardware interface. You could hook up your input/output lines (the Arduino Uno gives you a total of 20 I/O lines (although only 18 if you're controlling it via your computer) and if you need more you can always multiplex them via a shift register. You can either write your code directly to run on the Arduino, or set it up so it accepts commands from the computer to turn the pins on and off.
     
  3. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    You can't use Xcode alone. You probably also need some extra hardware to talk to from the Mac (either USB, networked micro, or a PCI card). Then you need to find and read the reference for that particular item of external hardware to determine what API it requires to send it commands. Then you may also need to write code on some IDE other than Xcode to program that external hardware (if it's an arduino, beagleboard or rasberry pi, for instance).
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
  5. Toptwo, May 10, 2012
    Last edited: May 10, 2012

    thread starter macrumors newbie

    Joined:
    May 10, 2012
    Location:
    taiwan

Share This Page