Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8606185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:01:54+00:00 2026-06-12T03:01:54+00:00

What is the standard method to read values on an Arduino from a C

  • 0

What is the standard method to read values on an Arduino from a C application?

I have an accelerometer and a few poentiometers which I would like to bind to Cocoa controls, an NSSlider for example.

My arduino is currently connected to: /dev/cu.usbmodem26431 and I can read the values printed by the AnalogReadSerial code sample in the Serial Monitor.

How do I read from /dev/cu.usbmodem26431 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:01:55+00:00Added an answer on June 12, 2026 at 3:01 am

    Cocoa Serial (Edit)

    Three methods of interfacing with Objective C are presented here

    http://arduino.cc/playground/Interfacing/Cocoa

    Arduino Serial

    If you know how to establish a Serial/USB connection then you can send the values as either string or binary to the Arduino.

    In the setup() method on the Arduino you establish as Serial connection like this.

    nb: using 115200 baud/speed for this example

    Serial.begin(115200);
    

    In the loop() method on the Arduino you can read data from the c application. here is a full Arduino example including how to send data back to the c application using Serial.print()

    int incomingByte = 0;   // for incoming serial data
    
    void setup() {
            Serial.begin(115200);     // opens serial port, sets data rate to 115200 bps
    }
    
    void loop() {
    
            // send data only when you receive data:
            if (Serial.available() > 0) {
                    // read the incoming byte:
                    incomingByte = Serial.read();
    
                    // say what you got:
                    Serial.print("I received: ");
                    Serial.println(incomingByte, DEC);
            }
    }
    

    Source http://arduino.cc/en/Serial/read

    The example above is very crude, you can use Serial.available() to see how much data is waiting to be read.

    For strings you might want to use a \n line terminator or other type of terminator as an indicator for the end of a packet (to know when it has been fully received).

    It is a good idea to design your own header and check sum to ensure data integrity but I don’t bother with check sums for simple unimportant projects.

    As an example, gps systems often send sentences when in string/text mode. If you look up the Arduino library called tinyGPS, you will see one way to read an entire sentence into different variables within an Arduino program.

    This is an NMEA GPS sentence, do not use the same header in your projects, instead, design your own. This is just an example of how you might transmit multiple values (int, string, float etc) to an Arduino

    $GPBWC,081837,,,,,,T,,M,,N,*13
    

    http://aprs.gids.nl/nmea/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB6 application which works with datetime values in SQL Server (which
I have a fairly standard .Net MVC Controller method: public ActionResult Add(Customer cust) {
I have this little crazy method that converts BigDecimal values into nice and readable
I have two string properties setup in my cocoa application's app delegate which are
I have a working login form in an asp.net application. Standard stuff with a
In my application I open a handle to shared memory that I read/write to/from.
The standard method to send data on a stream socket has always been to
Is there a standard method I can use in place of this custom method?
I am posting to a user's wall showing the standard dialog method: [facebook dialog:@feed
Is there a standard or reliable method already out there for a javascript framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.