Pages: [1]   Go Down
Author Topic: How to interface Arduino to MAC  (Read 1039 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an application in which I need to read the status of 4 switches and one analog voltage with a MAC MINI.  I have chosen an Arduino Micro and the input device and want the MAC to be able to read the status/values via a USB input.  I am a newbee, but the part of the Arduino code to read the inputs looks real simple so no worries there.  What I don't have a clue about is the communications between the MAC and the Arduino. 

Would someone point me in the correct direction?  Are there any existing libraries that will help?

Any help would be appreciated...
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To the Mac, the Arduino will look like a serial port.  Your program opens the port and can then send and receive characters.

What programming language are you using on the Mac?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Someone else will be doing the MAC software and can likely use whatever.... 

So, when you say the Arduino looks like a serial port, I assume when I plug it in, the MAC will assign it to a com port. 

Where can I learn about the protocol or how to configure the data on the Arduino so to MAC can ask for it.  Maybe my lack of knowledge is making this harder than it is. 
I remember from dinking with the Arduino environment several months ago, doing a tutorial where you would write values to the serial monitor app in the Arduino development environment.  I guess from the Arduino end, I would handle it like that.  Maybe every half second, output the values for the MAC to catch.  Or, would you set it up so the MAC sends a request to the Arduino and then the Arduino responds with the results?

I know this if very basic, but if I can get the basic operation understood, I can go off an do the pieces.  Do you recommend an approach for the MAC? 
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8701
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"Com Port" is more a Windows thing.  On the Mac (like Linux) it's a device file like /dev/tty.usbmodem3a21 (my Arduino UNO) or /dev/tty.usbserial-A6004peF (older Diecimila with FTDI chip).  It's the same name that shows up under Tools->Serial Port. 

There is also a corresponding "/dev/cu." device.  I don't know what that is for.

If you send data unsolicited you have to be careful not to send any faster than the program can process the data.  A few messages per second should not be a problem.  More than about 10 messages a second and you should probably only send when you get a request from the Mac.

Be sure to put in some kind of message framing so the program on the Mac can detect the start and end of messages and perhaps a checksum so the program on the Mac can check the message for validity.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the help.  I looked through some of the example code in the IDE.  I have a handle on it now.
Logged

Pages: [1]   Go Up
Jump to: