Pages: 1 [2] 3   Go Down
Author Topic: how to store different values of a pot to be called up latter?  (Read 3327 times)
0 Members and 1 Guest are viewing this topic.
Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
 
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
there is no such thing as a digital pot

Well here is a list of 390 of them. These are just the non volatile ones
http://ie.farnell.com/jsp/search/browse.jsp?N=2016+202722&Ntk=gensearch&Ntt=digital+pot&Ntx=mode+matchallpartial

Where as these are 350 of the volatile ones
http://ie.farnell.com/jsp/search/browse.jsp?N=2016+204266&Ntk=gensearch&Ntt=digital+pot&Ntx=mode+matchallpartial
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
there is no such thing as a digital pot

Well here is a list of 390 of them. These are just the non volatile ones
http://ie.farnell.com/jsp/search/browse.jsp?N=2016+202722&Ntk=gensearch&Ntt=digital+pot&Ntx=mode+matchallpartial

Where as these are 350 of the volatile ones
http://ie.farnell.com/jsp/search/browse.jsp?N=2016+204266&Ntk=gensearch&Ntt=digital+pot&Ntx=mode+matchallpartial

Hm, cool!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 03, 2012, 01:22:36 am by ElChiguete » Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, so I've had a few days testing this and now I'm back to square one...  smiley-confuse

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.

« Last Edit: February 06, 2012, 09:24:01 pm by ElChiguete » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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
  Serial.begin(9600);
// 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 ");
     Serial.println(recallValue1);
  }
  // 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:-
http://arduino.cc/en/Tutorial/SPIDigitalPot
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How else did you think you could do it?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

PS:
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
« Last Edit: February 10, 2012, 01:58:10 am by ElChiguete » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I thougth this works just like a pwm output.
This is what a PWM output does.
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

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:-
http://arduino.cc/forum/index.php/topic,91155.msg685189.html#msg685189
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 170
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 170
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

update: figured it out!  smiley-grin I'm very pleased with myself... smiley-wink
Now I'm trying to figure out how to call the array in its different order using a switch.
Logged

Pages: 1 [2] 3   Go Up
Jump to: