Results 1 to 9 of 9

Thread: Sending Variables to PC/another App - Arduino/

  1. #1

    Sending Variables to PC/another App - Arduino/

    Here is my problem:

    I want to control 3 "Sensor Arrays"

    each one containing a pan servo, IR sensor and a Sonar Sensor

    i want to basically just take my sensor values and servo position and send
    it over serial to a C++ program to use. I'm trying to figure out the best way
    to do this but I guess its to just get my readings and send them out with a
    Serial.print(xxxx); I guess I'm looking for a way to pass a variable but I don't
    guess thats possible. Let me know if I am barking up the wrong tree here.

  2. #2
    Join Date
    May 2008
    Location
    TN
    Posts
    853
    Images
    99
    Rep Power
    70

    Re: Sending Variables to PC/another App - Arduino/

    Something like this may be what you are looking for:

    Code:
    Serial.print(irReading);
    Serial.print(",");
    Serial.print(sonarReading);
    Serial.print(",");
    Serial.println(panServo);
    That will print out all of your sensor readings separated by commas followed by a new-line ("/n").
    "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
    -
    Einstein

    Don't be a HelpVampire

  3. #3

    Re: Sending Variables to PC/another App - Arduino/

    Yeah that is what I was afraid I was going to have to do, messy but oh well I understand the limits I just wanted to make sure I wasn't missing something since I'm no micro guru. Thanks Jes!

  4. #4
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    173

    Re: Sending Variables to PC/another App - Arduino/

    You could use sprintf(); and it would look prettier, but sprintf(); is an ugly dangerous memory-hogging function. I'd rather use a method that didn't look as clean but was internally cleaner.
    I Void Warranties�

  5. #5
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    124

    Re: Sending Variables to PC/another App - Arduino/

    You might also look around the Playground on Arduino.cc, there are a number of nearly turn-key PC<-->Arduino examples/libraries, several of which implement handshaking and error-recovery. Not sure that any use C++ for the PC though, since most of the examples are designed for cross-platform compatibility

    -Fergs

  6. #6
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    173

    Re: Sending Variables to PC/another App - Arduino/

    Yeah, Wiring <-> Processing is the classic way to implement the exchange and get a nice plotting engine in the process. The vast majority of samples will probably be Wiring <-> Processing
    I Void Warranties�

  7. #7

    Re: Sending Variables to PC/another App - Arduino/

    Thanks guys I looked at the processing stuff a little bit but I couldn't really wrap my head around it, I will take a little bit more in depth look, Thanks again for pointing me in the right direction everyone.

  8. #8
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    124

    Re: Sending Variables to PC/another App - Arduino/

    Quote Originally Posted by nagmier View Post
    Thanks guys I looked at the processing stuff a little bit but I couldn't really wrap my head around it, I will take a little bit more in depth look, Thanks again for pointing me in the right direction everyone.
    Processing is basically Java, with some simple extensions for graphics and opening serial ports. In theory, the syntax shouldn't be that far off of C++, if you can replace the serial/graphics stuff with suitable libraries.

    -Fergs

  9. #9
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    173

    Re: Sending Variables to PC/another App - Arduino/

    Nod. And obviously, you can send and receive packets in any language that can open a serial port, don't have to be tied to Processing - that's just where the largest chunk of sample code is going to come from.
    I Void Warranties�

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •