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

I wan't to be able to store the values of one or more pots in groups so I can call up them up latter but I don't find an example on this to look at it. How can this be done?
Logged

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

Simply store the reading in a variable.
Val = analogRead(pin);
Logged

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

Yeha I get that if I where to use just one readout but what I need is for example is this: to store the analogRead in position A, B and C, and then to be able to call back that info without using the pot when I hit bottom 1, 2 and 3.

Think of it like if I'm combining the analogRead of 3 pot that are the primary colors (red, blue and green) to create 3 other colors, so when I move the pots to get the desire new color I want to store the info of the pots in position A, then do the same in positions B and C. And now that I have A, B and C I want to be able to call back that info without moving the pots to the previous values that I stored in bottoms 1, 2 and 3.

And after I get to do that I wan't to be able to access this thru MIDI without having to press the bottom but with a MIDI comand.
« Last Edit: January 31, 2012, 09:47:10 am by ElChiguete » Logged

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

You still do the same, you store it in a variable then you can use it whenever you want in the sketch.
I think you are not asking the right question. Have you done a flow diagram about what you want to happen?
It would help if you said exactly what you want to do and why rather than talk about LEDs.
However you still store things in variables until you need to use them.
Logged

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

Sorry for my not so technical language but all of this is new to me and actually just yesterday I started reading about this and order the Arduino. Anyway it's for a guitar project and it's just like the LED example. I want to get X number of combinations of 3 pots to get different sounds and store them in bottoms so I can latter hit a bottom and bring back the info that was in the pot when I got it to the position that I wanted to. After I do this I want it to work thru MIDI.
Logged

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

OK a lot clearer thanks.

While you still use variables it is best to use a special type of variable called an array.
http://arduino.cc/en/Tutorial/Array
This is a variable you can store many different values in.
There are many ways of doing this and perhaps the best way is a two dimensional array, but to start with you should just use a one dimensional array and have one array variable for each of the pots.
You will need a store button, your program detects when that is pressed that takes the current three readings and puts them into the three arrays using the index (position in the array) of the bank or address of that sound.
Another button when pressed will read the value in the arrays and output them in some way.
So you need another form of control that determines what bank you are dealing with at the current time. Either a multi-position switch or a rotary encoder with some sort of display.

Quote
but all of this is new to me
While this is not a difficult project it is not a beginners one. Get to grips with the language, do a few tutorial examples:-
http://arduino.cc/hu/Tutorial/HomePage
Then you will be in a position to ask the right question, BUT MORE IMPORTANTLY, understand the answer when it is given to you.
Good luck

« Last Edit: January 31, 2012, 11:12:30 am by Grumpy_Mike » Logged

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

yeha for sure its a bit more difficult than making an LED blink jejeje, I started reading the Getting Started with Arduino book and I got a sense of the language involve, I just have to wait for it to get here to do get son hands on experience.

I'll keep you posted on the results.
Logged

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

Quote
its a bit more difficult than making an LED blink
Yes but try making three LEDs blink all at independently determined and different rates. Do that and you are well on your way to beginning to master the language.
Logged

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

While you still use variables it is best to use a special type of variable called an array.
http://arduino.cc/en/Tutorial/Array
This is a variable you can store many different values in.
There are many ways of doing this and perhaps the best way is a two dimensional array, but to start with you should just use a one dimensional array and have one array variable for each of the pots.


Geeze Mike, why not just throw the STL at the new guy?

If he knows its always going to be just three values, three separate variables would do nicely.
 
Logged

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

Quote
If he knows its always going to be just three values, three separate variables would do nicely.
But if he wants to recall more than just one sound he will need arrays. They are not that complicated anyway. I used them in my second ever computer program way back in 1971.
Logged

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

Quote
If he knows its always going to be just three values, three separate variables would do nicely.
But if he wants to recall more than just one sound he will need arrays. They are not that complicated anyway. I used them in my second ever computer program way back in 1971.

Yeah he will, and yeah they are not really that hard, even for a newbie. But the STL is so much nicer than a vanilla array!
Logged

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

well can you tell me about the STL too?
Logged

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

well can you tell me about the STL too?

The STL is the Standard Template Library. Without getting into all the fun about how great templates are, this is a series of containers from fairly simple to fairly complex. But, the complexity is largely hidden from the developer. This are not the easiest library to use, but its not the hardest either.

A "container" is a fancy way of saying that its some code that holds and organizes data. With the STL, you can have items sorted, indexed and organized for fast searching in varying ways. Which way you pick will depend on how you want to organize you r data and how you want to search it. What does not matter is what type of data it is (thanks to the magic of templates). The STL works equally well - and the same way - with all kinds of data.

If you want to store your samples in order, you would use a Vector.

There is an implementation of the STL for Arduino here:

http://andybrown.me.uk/ws/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/

If you want to learn more about the STL in general, then Google it and you'll find a wealth of information.
Logged

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

Well today the Arduino is arriving at my PO Box in Miami and if I'm lucky it should get here by friday  smiley-lol

Still after reading more on how everything works I have questions on my project:

1) I understand that I will be combining all sort of sketches to make it work, but I still don't find and example of something similar to what I will do. Lets say that I have a RGB LED and using 3 pots to control each base color I make a combination that I store in button A, then I make another combination in button B so now that I have that I can go from one combination to the other when I press button A or B... I think that if I can do THAT my project will be done!

2) going back to the pot thing, can it be done? can one store the value of a normal analog pot and recall that value without physically moving the pot? or do I need a digital pot?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34122
Solder is electric glue
View Profile
WWW
 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!
Logged

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