Hey yall
i have a seniors project which im currently working on
Im making a robotic hand which mimics the hand of its user
I’m using 5 flex sensors which control five servos via an arduino uno microcontroller
5V----------
|
Pin 0----- 100K ------ One end of flex sensor---------
| |
| Flex Sensor
| |
Ground-------------------other end of flex sensor-----
this is how i’ve connected the flex sensors to the arduino, now ive got five of theses in different analog pins,
and the servos connected to the digital
my problem is that, when i go to bend the flex sensor the servo rotates the full 180 degrees, but if i want to
stop it at a sertain point in that rotation, say half way, the servo kinda stutters and jolts around and dosnt stay in the place i want it to.
heres the code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int potpin = 0; // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;
int potpin5 = 4;
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(8); // attaches the servo on pin 9 to the servo object
myservo2.attach(9);
myservo3.attach(10);
myservo4.attach(11);
myservo5.attach(12);
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val= analogRead(potpin2);
val= analogRead(potpin3);
val= analogRead(potpin4);
val= analogRead(potpin5);
val = map(val, 150, 179, 90, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
myservo2.write(val);
myservo3.write(val);
myservo4.write(val);
myservo5.write(val);
delay(5); // waits for the servo to get there
}
i’ve cut and pasted from codes i’ve found o n the net, and made my own, also the code line val=map( val, 150,179,90,179), i tried to use the smae values as the ones on the example in the arduino libary, val = map(val, 0, 1023, 0, 179)and nothing happened so i messed around with the values and this combo seems to work
can some one please help me,
have i wrote the code wrong?
are my servos or sensors stuffed?
please help
thz
p.s be nice this is my first try at this stuff =D