Whatever your knowledge can help me

hi i am in search of answers
to build my follow focus
that's what I want to accomplish? <Is to generate a value with a potentiometer, and record it on a button
then generate a second value with the same potentiometer, and record the second value in a second button, so that later when I push the button1, the servo read the Balor of button1 and remains in that position, and when I press the button 2, The servo read the button2 and remains in that position
and thus be able to designate values ??in the buttons without a computer NEEDS

example of what I want to accomplish <
I put the potentiometer in the value 90 (which makes the servo fence to 90 °)

I push the button1 (the arduino reads the value and stores)

I put the potentiometer in the value 70 (which makes the servo fence to 70 °)

I push the button2 (the arduino reads the value and stores)

then every time I push the button1 the arduino sends the servo to position 90 °
and the same for button 2

and I want to change the values ??for each button every time after running several times

sounds good
but my knowledge is not enough for me to do it myself

I read a lot
but my English is very poor
I am asking for help, whatever your knowledge can help me.
any answer can be helpful

I do not seek it only in this way, if there is another way of doing the same result I would like to know it easier
Thanks for your answers
which code do I need?

Hi Myriam,

you need to check the examples:

they contain 99% of the code you need

thanks for your Reply.
I did not know the existence of (EEPROM)
but my big problem is that I never created a code and I do not know how to put the value of (EEPROM) on a button
and I do not know how to put the (clean EEPROM) on a button
I continued reading the examples

OK, braindumped some code for you,

  • connect the potmeter with one side to 5V - other side to GND - and sliderpin (middle) to A0
  • connect the servo to pin 9
  • connect button1 to GND and pin 4
  • connect button2 to GND and pin 5

I left out the EEPROM part, just use two integers as memory for now.

Code compiles but it is not tested if it does exactly what you want, but it should get you started.

// 
//    FILE: test.pde
//  AUTHOR: rob tillaart
// VERSION: 0.1.00
// PURPOSE: servo test app
//
// HISTORY: 
// 0.1.00 - 2011-05-15 initial version
// 

#include <Servo.h> 

#define BUTTON1 	4
#define BUTTON2 	5
#define POTPIN 		A0
#define SERVOPIN	9

int pot = 0;		
int servoValue;

Servo myservo;


// two memories to hold servo positions
int mem1 = -1;
int mem2 = -1;

void setup()
{
  Serial.begin(9600);
  Serial.println("Start ..");
  
  pinMode(BUTTON1, INPUT);
  pinMode(BUTTON2, INPUT);
  digitalWrite(BUTTON1, HIGH);  // internal pullup
  digitalWrite(BUTTON2, HIGH);  // internal pullup
  
  myservo.attach(9);
  myservo.write(90);  // set servo to mid-point
}

void loop()
{
  // READ POT
  pot = analogRead(POTPIN)/4;  // 0..1023
  servoValue = pot/4; 
    
  // CHECK BUTTONS PRESSED
  if (digitalRead(BUTTON1) == LOW)  // pressed 
  {
     if (mem1 == -1)   	// not pressed before
	 {
	   mem1 = servoValue;	// remember current value
	 }
	 else 
	 {
	   servoValue = mem1;	// use remembered value
	 }
  }
  if (digitalRead(BUTTON2) == LOW)   
  {
     if (mem2 == -1)
	 {
	   mem2 = servoValue;
	 }
	 else 
	 {
	   servoValue = mem2;
	 }
  }
  
  // SET SERVO
  Serial.print("SERVO: ");
  Serial.println(servoValue);
  
  myservo.write(servoValue);
  delay(10); 
}

Hi Myriam,
I see you crossposted your question, that not appreciated on this forum.
It wastes time for everyone who tries to help (Switching between all the same threads) and for you to collect the answers.

Please remove this thread and let the discussion focus at => http://arduino.cc/forum/index.php/topic,61240.0.html

hi robtillaart

excuse me
is my first post and I do not know this site very well
infirst I did not know where to post

I just try to find answers

now I understand more how it works

you did all this code for me ??????
thank you very much

I will study well to then be able to create my own codes

by the time today is Sunday and I have no buttons
but tomorrow I will buy it and taste it

if there is anything I can help you tell me

about photography, cameras, video cameras, photo editing programs video, if your need is a program I can I give it to you

I already download the code at the plate
works great, I just had to change some values ??in this

pot = analogRead (POTPIN) / 4 / / 0 .. 1023
servoValue = pot / 4;

the servo just turned 63 ° but now everything is fix it
Now I only need to get the servo to stay in the value of each button

but thank you very much robtillaart you gave me a very good step