Hi guys, I'm using Json library, and stock many data in json array
for (i=0;i<148; i = i + 1) {
array.add(analogRead(A0));
delay(68);
}
now the problem each time I print the array:
array.printTo(Serial);
the loop give me the same values it took at it first run, so I need to reset the arduino to get a new values, my question is there's any function to free or flush the memory used by this array, so everytile I run the loop I will get a new values?
Vu1000:
Hi guys, I'm using Json library, and stock many data in json array
for (i=0;i<148; i = i + 1) {
array.add(analogRead(A0));
delay(68);
}
now the problem each time I print the array:
array.printTo(Serial);
the loop give me the same values it took at it first run, so I need to reset the arduino to get a new values, my question is there's any function to free or flush the memory used by this array, so everytile I run the loop I will get a new values?
Thanks sorry for my English.
the answer probably lies in the JSON library you are using.
If you cannot find the class member function yourself, you could post the .h and .cpp file.
Hi BulldogLowell many thanks for your reply, the library has so many .hpp files I don't know which one has this function, I will start search for this function in all the .hpp file, I have also posted the whole library here.
The JsonArray.hpp file defines the array functions. You can add() a object, as you are doing. You can removeAt() an object, if you know it's position. I can't see how you determine how many objects are in the array, but, if you know that, you can obviously remove each one, starting with the last one and working backwards.
Hi Pauls many thanks for your help, the removeAt() did some changes, it has delete all the array elements, but I still can't write over it again, so now when I run the loop for the second time it gives me an empty array...maybe the problem in my code, I will try to improve it because I think the removeAt() is the right function.