Go Down

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

abhinav_1615

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() {
 
  base.attach(3);
  arm1.attach(5);

}

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);
base.write(s1);

delay(10);

}


Best of luck!

zoomkat

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.

abhinav_1615

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.

http://arduino.cc/en/Reference/HomePage

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!

abhinav_1615

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.

abhinav_1615

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....
like..

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


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

how to implement above  in arduino programming....

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

zoomkat

#8
Jul 18, 2013, 05:39 am Last Edit: Jul 18, 2013, 05:42 am by zoomkat Reason: 1
Quote
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:

https://www.google.com/search?as_q=flex+sensor&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up