chipKIT® Development Platform

Inspired by Arduino™

Example for cJSON

Created Wed, 27 Nov 2013 16:30:18 +0000 by t90add


t90add

Wed, 27 Nov 2013 16:30:18 +0000

Hi,

Does anybody have an example on how to use cJSON to make an array from analogRead() ?

Something like this:

aJsonObject *createMessage()
{
  aJsonObject *msg = aJson.createObject();

  int analogValues[6];
  for (int i = 0; i < 6; i++) {
    analogValues[i] = analogRead(i);
  }
  aJsonObject *analog = aJson.createIntArray(analogValues, 6);
  aJson.addItemToObject(msg, "analog", analog);

  return msg;
}

Thanks