storing and recalling values on a digital pot using Arduino

I'm new to Arduino and while the tutorials are good they don't give me a clear example of what I want.

I want to be able to manually set the value (brightness) by using a normal pot... but use the digital pot to recall those stored values. I want to use a digital pot (like the AD5206) to be able to control lets say the output values of 2 LEDs and store them in 3 presets, for example:

  • boton 1 will have LED A at max value and LED B at half value
  • boton 2 will have both LEDs at half value
  • and boton 3, have LED A at half value and LED B at max value

These presets will be recalled by presing one of 3 bottons so I can recall the different values (brigthness) of the two LEDs at the same time.

Can someone help me on this?

http://www.arduino.cc/en/Reference/EEPROM

My problem is setting up and writing the hole sketch to make it work since I can’t find an example for something close to what I want. Like I said I’m new on programing languages.

ElChiguete: My problem is setting up and writing the hole sketch to make it work since I can't find an example for something close to what I want. Like I said I'm new on programing languages.

Start small. Get the buttons working, then get the LEDs working, then get the digital pots working, then put it all together.

So you have Arduino, a pot, 2 leds with resistors, and some buttons.

You need to be able to tell the project when you want to set the values and when to recall them.

If you can set the leds while connected to a PC then your options are much wider, you won't even need the pot.

You can store settings in the EEPROM using the EEPROM library. It stores bytes, you may have to learn how to break an int into a high byte and a low byte to store but that's a detail. The fun may be in how many settings you can store, how your sketch can tell when it has reached the last setting and how you want to choose which to use. What is in EEPROM will be there even after power is turned off and back on. One of the last things you want to do is write the same few bytes of EEPROM over and over since EEPROM is electronic paper that only erases so many times... maybe 50,000 or 100,000 times.

What Aarch says.... +1 for sure. Don't write a big sketch and then see how to make it work, do tests and pieces until you know how each works then fold them together.

You don't need a digital pot. You control the LED brightness with PWM signals from an analogWrite() You read the real pot into a variable, scale it to fit the PWM range and then write it out to the LED. You store that value into EEPROM if you want it to persist over a power down. When you want to recall the value you read the EEPROM and write it back to the LED pin.

GoForSmoke: If you can set the leds while connected to a PC then your options are much wider, you won't even need the pot.

I could use the PC to test the bottons but I will need the pot for the idea behind the final product.

Grumpy_Mike: You don't need a digital pot. You control the LED brightness with PWM signals from an analogWrite().

Yes this is true for just the LEDs but the actuall final proyect is not with LED, I just made the reference to describe the general idea of the proyect.

ElChiguete:

GoForSmoke: If you can set the leds while connected to a PC then your options are much wider, you won't even need the pot.

I could use the PC to test the bottons but I will need the pot for the idea behind the final product.

You can feed Arduino numbers through serial monitor and store the ones that look right into EEPROM. Next time you power up unconnected, Arduino will fail Serial.begin(). That would tell the sketch to use buttons for playback.

If you want to both set the lights and play back unconnected then you will need to come up with how you tell Arduino not just push button for playback but for record too.

There's a sketch in the Playground that uses a led as both light and sensor. It adjusts itself.

just made the reference to describe the general idea of the proyect.

And I just made referance to the LED to describe the idea of my answer.