Go Down

Topic: controlling 5 servo with values from flex sensor (Read 3673 times) previous topic - next topic


i want to make an robotic hand that should be controlled by flex sensor.
all servo should be moving
simultaneously... without disturbing movement of other servos....
can anyone help me with code i have just bought an uno dont know much of arduino programming..
i know programming through atmega16 using eclipse...
please help me out this will be highly grateful....  :) :) :) :)

Drew Davis

The program below uses two analog sensors to control two servos. This does not have all 5 servos you need, but should give you a place to start. Adding in the other sensors/servos should be easy. It's not perfect but It does work…

Code: [Select]

#include <Servo.h>

int m1 = .1759530792; 
int s1 = 90;
int s3 = 90;
Servo base;
Servo arm1;


void setup() {


void loop() {

   s1 = analogRead(A0); // read the sensor
   s3 = analogRead(A1); // read the sensor
   s1 = s1 * .1759530792; // math (180 /1023 )
   s3 = s3 * .3519061584; // math (360 / 1023)

arm1.write (s3);



Best of luck!


What flex sensors are being used? They may need to be setup as part of a voltage divider. Also, a forum search for flex sensor should produce previous discussions on the subject.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.


thanz drew davis .....
can you suggest me sites that could illustrate programming syntax of arduino....
it would be so nice of you..... :) :) :) :) 

Drew Davis

This might be helpful.


Also, are you going to have one flex sensor per servo or one flex sensor for all the servos? That will change the programming aspic quite a bit.

Best of luck!


i will be using 5 flex sensor.....
but i want to move a servo for a different combination of the sensors..... like nested if.....
and i want to do this with all the servos....
can you please show me how can i do that.....
thanz........ :) :) :) :) :)

Drew Davis

Do you know how analog sensors work? They return a value between 0 & 1023. My guess would be the harder you flex the sensor the higher the value goes but you will have to test it. 

I need a little more info to help you out. Are you building a robot arm with the servos? Are you going to use a glove with the sensors in it? If you are do you want the robot arm to mimic the position your fingers are in?  If not tell us the combinations you will be using. Please clearly describe your project. Tell us everything about it.  What exactly are you doing.


yes i know the way flex sensor work.....and you are right harder we bend higher the output....
and yes i am making a robotic arm....but i am not governing it through hand glove with sensors in it like animatronic hand....
my task is to make a robotic hand that function when it find different bending on different points.......
i want that arm to function when specific values in the sensors....

while (1)
analog read sensor 1
analog read sensor 2
analog read sensor 3
if(ConditionOne && ConditionTwo && ConditionThree)
  Code to execute servo

i want to do this for all five servos where conditions are values from sensors

how to implement above  in arduino programming....

thanz.... :) :) :) :) :)


Jul 18, 2013, 05:39 am Last Edit: Jul 18, 2013, 05:42 am by zoomkat Reason: 1
i want that arm to function when specific values in the sensors....

How are you getting any specific values from the sensors, and what are they? Do you have a link to the sensors? If they are just a variable resistor setup, you will probably have to add some more components.

edit: possible reading material for your project:

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131