potentiometer recorder/loop

could anyone help me with this one?

i want to be able to record the variation of a potentiometer and then repeat/loop that variation endlessly until reset is pressed. this would be controlling the fading of a led with one of the pwm outputs.

maybe a momentary switch to start and to stop the recording funtion would help this operation.

is this possible or anyone tryed this and it's willing to share?

this is the code i got so far(just the fading led part) :

  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 

 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 9
 * LED cathode (short leg) attached to ground

 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.

 Created by David Cuartielles
 Modified 16 Jun 2009
 By Tom Igoe



int XsensorPin = 0;    // select the input pin for the potentiometer
int XoutPin = 9;      // select the pin for the LED
int XsensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(XoutPin, OUTPUT);    

void loop() {
  int XsensorValue = analogRead(XsensorPin) / 4;   analogWrite(XoutPin, XsensorValue); 

thanks for your atention

Recording the values would simply be a matter of storing them in an array. The problem is that loop runs several million times a second, so that's a lot of data to store. The Arduino does not have the memory to do that.

You can cut down on the amount of memory be only storing the value when it has changed significantly. The trade off is that you also need to store how long the value is to remain at that level.

For how long a period of time do you want to record the pot level? How frequently does it need to be sampled? How often will it change during the "recording" period?

i still don't know much about programing to understand what a storing array is :-/ do you know any exemple that uses this?

10 seconds would be cool for a total loop time(but more time, the merrier). definitely the frequency of samples per second could be reduced to something like 50(or probably even lower) times per second and when no value is changed it would hold the last one(maybe this would save some memory, am i assuming it right?)

i mean, probably 10 or 15 samples per second would be fine!

Completely untested, but could inspire some ideas: http://arduino.pastebin.com/FLsAEYxf

thanks a lot!

i'm not at home right now so i can't test it today, but i'll check it tomorrow and report if it works.

thanks again