Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ytk

macrumors 6502
Jul 8, 2010
252
5
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.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
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).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.