Thread: serial

  1. #1
    Registered User
    Join Date
    Feb 2011
    Location
    Oslo, Norway
    Posts
    5

    serial

    Hi all.
    I have a arduino project, with serial comminication toward my PC.

    When I send a serial command from my computer, I send data like values for setpoints etc. like:
    A setpoint for light, "k1: 255," or turn on/of things.

    There's manny different values given from PC. So I split the values and replace the space between "k1: 255," so its like this "k1:255,".

    In VB.net i then use "left() and len()" function to then choose next things to do.
    I have:
    k - setpoints, 0-100%, or setpoints for sensors
    w - setpoint on/off
    t - timers

    So when I read the first letter in the array, I deside if its a k, w or t.
    Then I use the hole array to set a textbox.

    So my question regarding C is:
    I wanna do similar in "C". I want to get my serial data, and place the "data" right place.
    Like, I send a 0-255 value from computer, "k1: 244,", I retrieve this in "arduino" and I want to give a light brightness. analogWrite(ledPin10, brightness);
    So I need to split my input, (k1: 244,) and store value so I could get it later in program.


    Annyone?
    -Andy

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You can use sprintf() to combine the parts of your string.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. Music Programming - Serial Matrix Display (Help needed)
    By CrazyHorse in forum C Programming
    Replies: 1
    Last Post: 11-13-2007, 04:28 PM
  3. Music Programming - Serial Matrix Display
    By CrazyHorse in forum C Programming
    Replies: 1
    Last Post: 11-12-2007, 04:16 PM
  4. Please help with serial communication problem - Long
    By spdylude in forum Windows Programming
    Replies: 3
    Last Post: 04-06-2005, 09:41 AM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM