hi guys
I got this code from internet and it works well for my puppet ; anyway i'd like to take out the potentiometer "eyelid contro" which i don't need.
could you help me on the code pls ?
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
#include <Servo.h>
Servo x; // create servo object to control a servo
Servo y;
Servo b;
Servo t;
int xpotpin = 1; // analog pin used to connect the potentiometer
int ypotpin = 0;
int opin = 2;
int bpin = 10;
int xval; // variable to read the value from the analog pin
int yval;
int bval;
int tval;
int xxval;
int yyval;
int oval;
int blinkval;
void setup() {
pinMode(bpin, INPUT);
x.attach(8); // attaches the servo on pin 9 to the servo object
y.attach(9);
b.attach(6);
t.attach(7);
Serial.begin(9600);
}
void loop() {
blinkval = digitalRead(bpin);
oval = analogRead(opin);
xval = analogRead(xpotpin); // reads the value of the potentiometer (value between 0 and 1023)
yval = analogRead(ypotpin);
oval = map(oval, 0, 1023, -10, 10);
xxval = map(xval, 0, 1023, 0, 80); // scale it to use it with the servo (value between 0 and 180)
yyval = map(yval, 0, 1023, 0, 80);
if (blinkval == 0){
bval = 50;
tval = 50;
b.write(bval);
t.write(tval);
} else {
bval = map(yval, 0, 1023, 110, 150);
tval = map(yval, 0, 1023, 120, 90 );
b.write(bval + oval);
t.write(tval + oval);
}
x.write(xxval); // sets the servo position according to the scaled value
y.write(yyval);
delay(5); // waits for the servo to get there
}
