Go Down

Topic: how to store different values of a pot to be called up latter? (Read 10534 times) previous topic - next topic


I can't believe it.
You criticise me for telling a beginner about an array and then you recommend him use a STL!

LOL! Well I was joking, but I only explained the STL because he asked. I don't think he should try it. But if he really needs to store a list of numbers the Vector might be easier than an array.

To answer his questions, there is no such thing as a digital pot. All pots are variable resistors. When you measure their value you ger a number, which you then store in memory.  What you want to do is very straightforward and is something a beginner to programming can handle.



Feb 03, 2012, 02:30 am Last Edit: Feb 03, 2012, 07:22 am by ElChiguete Reason: 1
well the Arduino came a day early!!! so the way I see it I have to first be able to read 3 pots and store those values in button ¨A¨, then do the same to button ¨B¨ and ¨C¨, those stored values on each button have to be stored in the EEPROM so I can use them after I turn off the device and be overwritten if I want new pot values.


I don't know what you mean by "bottom," but let me suggest this. There are examples in the environment under the file menu. Start with the EEPROM example. Forget the pots for now. Make sure you understand everything about the EEPROM example, ask questions, then move on.


sorry my bad, it buttons... I was going to fix it but forgot too....


Feb 06, 2012, 10:48 pm Last Edit: Feb 07, 2012, 03:24 am by ElChiguete Reason: 1
Ok, so I've had a few days testing this and now I'm back to square one...  :~

Lets start simple, how do I read the value from an analog pot so I can store different values to different buttons?

My final proyect is to place the Arduino between the outputs of the pots on a pedal and the inputs that go to the board to first save and then load different outputValues of the pots:

... but that is the final idea, now I just wan't to know how to do it on 1 pot. I think I can use this http://arduino.cc/en/Tutorial/AnalogInOutSerial but need a way to save the outputValue that goes to the LED and save it in a button so I can load it when that button gets pressed. After that make it work with different outputValues of the pot to 3 buttons. If you guys can help me on this I can be on my way to complete my project.


I know I'm asking for maybe too much help but I don't seem to find a sketch to base my project from that uses all that I need.


Well yes you are asking a lot.
I have written this to read from the pot and print out the value when it is recalled.
You need two buttons, one to tell the system to store the pot value and the other to tell it to recall it.
Disclaimer:- This code compiles but I have not tested it.

Code: [Select]
// Sketch to read a pot on A0 and store the value in EEPROM
// when button1 is pressed. When buttonRecall is pressed the value is recoverd from the EEPROM and
// printed out on the serial port
// Buttons wired between input pin and ground
#include <EEPROM.h>

#define button1 2      // button to store the pot value
#define buttonRecall 3  // button to recall the pot value
#define pot1Input 0     // analog input for pot 1

int pot1Value, lastButton1, recallValue1, lastButtonRecall;

void setup(){
  pinMode(button1, INPUT);
  digitalWrite(button1, HIGH); // turn on the internal pull up resistor
  pinMode(buttonRecall, INPUT);
  digitalWrite(buttonRecall, HIGH); // turn on the internal pull up resistor
// initilise button variables
  lastButtonRecall = digitalRead(buttonRecall);
  lastButton1 = digitalRead(button1);

void loop(){
   // get the value of the buttons
   int button1Value = digitalRead(button1);
   int buttonRecallVlaue = digitalRead(buttonRecall);
  if(button1Value == LOW && lastButton1 == HIGH) { // button pressed for the first time
   pot1Value = analogRead(pot1Input); // get the value on the pot
   // use the first two bytes in the EEPROM to store the 10 bit value from the pot
     EEPROM.write(0, pot1Value >> 8); // store the most significant byte
     EEPROM.write(1, pot1Value & 0xff); // store the least significant byte
     delay(20); // debounce dealy
   if(buttonRecallVlaue == LOW && lastButtonRecall == HIGH) { // button pressed for the first time
     recallValue1 = EEPROM.read(0) << 8; // get the most significant byte
     recallValue1 |= EEPROM.read(1); // merge it with the least significant byte
     delay(20); // debounce dealy
     // now do something with the recalled value
     // in this case just print it
     Serial.print("Recalled value is ");
  // save for next time round the loop
  lastButtonRecall = buttonRecallVlaue;
  lastButton1 = button1Value;

However, the difficult part in your project is presenting a pot value to the output. This vitally depends on what the output is being connected to and what voltages there are on that device.
This link shows you the basics:-


So I need to use a digital pot to have the different output pot values?



Feb 10, 2012, 07:24 am Last Edit: Feb 10, 2012, 07:58 am by ElChiguete Reason: 1

How else did you think you could do it?

Don't know, since I'm new at this I'm clueless on how all of this works together really! I thougth this works just like a pwm output.

Last couple of days I haven't taken time to make progress on this but I've been giving it thought, and I don't know if I have been looking at it from the wrong point of view. What I want this to do is just to store the value that's coming out of the pots on the pedal in say 3 different positions (at 25%, 60% and 100% of the pot) and use the Arduino to send that value out in to the pedals own board just like if I would have instantly change the pot manually.

This guy made something similar, but he stored different types of waves to generate different ways to make on pot move.

video: http://www.dailymotion.com/video/xa7til_collin-s-lab-guitar-pedal-hacking-w_school
code: http://code.google.com/p/makezine/downloads/list?can=2&q=pedal&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount


I thougth this works just like a pwm output.

This is what a PWM output does.

Yes Colin used a digital pot. But note he did that with one pot on one peddle. Using multiple peddle is a bit more problematic
Read what I had to say about it in this thread:-


Hey guys, this thread seems relevant to me and I'm kind of getting lost here - I'm following all the links and reading the references... So I'd like to introduce my challenge and would appreciate a few pointers to help me sort the relevant things for me. I'm trying to "record" pot movement into an array, while using the data to move a servo. Then I wish to recall the data from the array (with a switch) and re create the same movement of the servo (i.e. move it again in the exact manner). What I can't wrap my around is how to create a process that stacks the continuous data from the servo into the array. I hope my "intrusion" into this thread is fine - It seems relevant here, right?  :smiley-slim:
thank you.


update: figured it out!  :D I'm very pleased with myself... ;)
Now I'm trying to figure out how to call the array in its different order using a switch.

Go Up