Hello everyone,
As part of a project for school, I'll make a hand and a robotic arm, the arm and hand are controlled with motion sensors. The sensors will be sewn on two gloves, and to control the other hand to the arm, I will use voltage dividers on the motion sensors, the value for the change in trying upon movement of the finger.
To order and connect the arm and hand gloves, I will use three XBee modules, to send and receive data using WiFi, and three Arduino for control and management of each signal.
I already do all the mechanical, and do the gloves, I still have to do the code, and that's my problem: /.
I made a code but not work when I just use a sensor to a must this works, but if I put it all together nothing function, hand works all alone, it moves randomly.
I apologize for my English, I use google translation because I'm french
here is the code for the hand, the arm is the same problem:
To send hand :
int position0 = 0;
int position1 = 0;
int position2 = 0;
int position3 = 0;
int position4 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int flex0 = analogRead(A0);
int flex1 = analogRead(A1);
int flex2 = analogRead(A2);
int flex3 = analogRead(A3);
int flex4 = analogRead(A4);
int position0 = map(flex0, 400, 700, 0, 255);
Serial.write(position0);
delay(10);
int position1= map(flex1, 410, 740, 0, 255);
Serial.write(position1);
delay(10);
int position2 = map(flex2, 760, 420, 0, 255);
Serial.write(position2);
delay(10);
int position3 = map(flex3, 700, 400, 0, 255);
Serial.write(position3);
delay(10);
int position4 = map(flex4, 700, 400, 0, 255);
Serial.write(position4);
delay(10);
}
Here is the one of the reception:
#include <Servo.h>
//Creation des l'objets de la classe servo
Servo MonServo0, MonServo1, MonServo2,MonServo3, MonServo4;
int doigtPin0 = 7;
int doigtPin1 = 6;
int doigtPin2 = 5;
int doigtPin3 = 4;
int doigtPin4 = 3;
int flex0 = 0;
int flex1 = 0;
int flex2 = 0;
int flex3 = 0;
int flex4 = 0;
int position0 = 0;
int position1 = 0;
int position2 = 0;
int position3 = 0;
int position4 = 0;
void setup() {
Serial.begin(9600);
Serial.println( "Serial Start" );
// put your setup code here, to run once:
MonServo0.attach(doigtPin0);
MonServo1.attach(doigtPin1);
MonServo2.attach(doigtPin2);
MonServo3.attach(doigtPin3);
MonServo4.attach(doigtPin4);
MonServo0.write( position0 );
MonServo1.write( position1 );
MonServo2.write( position2 );
MonServo3.write( position3 );
MonServo4.write( position4 );
}
void loop() {
if (Serial.available() > 0) {
flex0 = Serial.read();
int position0 = map(flex0, 0, 255, -360, 180);
MonServo0.write(position0);
delay(10);
flex1 = Serial.read();
int position1= map(flex1, 0, 255, -360, 180);
MonServo1.write(position1);
delay(10);
flex2 = Serial.read();
int position2 = map(flex2, 0, 255, 0, 500);
MonServo2.write(position2);
delay(10);
flex3 = Serial.read();
int position3 = map(flex3, 0, 255, 0, 500);
MonServo3.write(position3);
delay(10);
flex4 = Serial.read();
int position4 = map(flex4,0, 255, 0, 500);
MonServo4.write(position4);
delay(10);
}
}
thank you for your help ![]()


