Analog input to queue

Hello people,

In order to reduce memory usage in arduino, I decided to use linked list.
So, basically, I want my analogRead value to be pushed in the structure. But! somehow functions I wrote don’t work.
I made some changes in this library [http://playground.arduino.cc/Code/QueueList] - wrote couple of functions, which were successfully compiled.
But, when I used IDE just to check if my code is working or not, Serial Printer gave me nothing…

I tried running code like this:

#include <QueueList.h>

QueueList mic;
int SV;
void setup() {
// put your setup code here, to run once:
mic.setPrinter (Serial);

}

void loop() {
// put your main code here, to run repeatedly:
SV=analogRead(A0);
mic.push(SV);
Serial.println (mic.pop ());
delay(100);

}

and then following example I decided to modify it and rearranged code like this:
#include <QueueList.h>

QueueList mic;
int SV;
void setup() {
// put your setup code here, to run once:
mic.setPrinter (Serial);
while (1)
{
SV=analogRead(A0);
mic.push(SV);
Serial.println (mic.pop ());
delay(100);
}
}

void loop() {
// put your main code here, to run repeatedly:

}

for both of the function upload is successful =//

attaching you my queue library.

Thank you in advance guys!!!

I appreciate any comments…

QueueList.h (5.54 KB)

Would it be sufficient to save your data into an array used as a circular buffer?

If so there is no need for any library. Just use two variables to index the head and tail of the buffer. Add the next data item at the tail and remove each item at the head. After each addition or removal increment the index. If the index points beyond the end of the array set it back to 0. If the tail and the head point to the same element the buffer is empty.

...R

In order to reduce memory usage in arduino, I decided to use linked list.

Erm, fail at first post, linked list will increase memory usage.

Robin2:
Would it be sufficient to save your data into an array used as a circular buffer?

If so there is no need for any library. Just use two variables to index the head and tail of the buffer. Add the next data item at the tail and remove each item at the head. After each addition or removal increment the index. If the index points beyond the end of the array set it back to 0. If the tail and the head point to the same element the buffer is empty.

...R

I thought about it too. Ok, thank you so much!

MarkT:
Erm, fail at first post, linked list will increase memory usage.

Thank you. I didn't know about it =//