Go Down

Topic: Robotic hand (Read 965 times) previous topic - next topic

altairscorpio

Hello everyone!
I need help with a project.

In the project I using 2x arduino's,,, 5 Potenciometers controlled 5 Servo Motor by hc-06 and hc-05 Bluetooth.

Now I trying with one potenciometer and one servo...

In ,,BT" code everything is OK, I getting correct values(from 0 to 179), but i don't know what's wrong with another ,,BTservo" code because servo just repeat moving about 5 degres forward and back per 100 miliseconds, I try change value, by rotating potenciometer(value have changed), but it's still repeating move...

Can someone help me?

PaulS

Why does BTServo.ino have Serial.begin() but no Serial.print() or Serial.println() statements? How do you know what you are getting?
The art of getting good answers lies in asking good questions.

altairscorpio

Why does BTServo.ino have Serial.begin() but no Serial.print() or Serial.println() statements? How do you know what you are getting?
Can you change the code, that it would work?

PaulS

Quote
Can you change the code, that it would work?
If I knew how it was broken, I could. But, it would be far better for you to learn how it is broken, and how to fix it yourself.

The first step in that process is to see how the data being received compares to the data being sent. Any discrepancies need to be handled.

You have Serial.print() statements in the sending code. Add some to the receiving code. Are you receiving what you think you are?
The art of getting good answers lies in asking good questions.

altairscorpio

Hey everyone! I've an idea, i uploaded video with two codes. https://youtu.be/qBLS0X_9Vks
These two codes are different than I uploaded in this forum, and just look how it works with this two codes --->
----------------------------------------------
GLOVE:
int Finger1 = 1;
int Finger2 = 2;
int Finger3 = 3;
int Finger4 = 3;
int Finger5 = 5;

void setup()
{
Serial.begin(9600);
}

void loop()
{
byte servoValue1;
byte servoValue2;
byte servoValue3;
byte servoValue4;
byte servoValue5;

int FingerV1 = analogRead(Finger1);
int FingerV2 = analogRead(Finger2);
int FingerV3 = analogRead(Finger3);
int FingerV4 = analogRead(Finger4);
int FingerV5 = analogRead(Finger5);

byte servoVal1 = map(FingerV1,0, 1023, 0, 179);
byte servoVal2 = map(FingerV2,0, 1023, 0, 179);
byte servoVal3 = map(FingerV3,0, 1023, 0, 179);
byte servoVal4 = map(FingerV4,0, 1023, 0, 179);
byte servoVal5 = map(FingerV5,0, 1023, 0, 179);

Serial.println(servoVal1);
Serial.println(servoVal2);
Serial.println(servoVal3);
Serial.println(servoVal4);
Serial.println(servoVal5);

delay(1000);
}
---------------------------------------------------
AND HAND:
#include <Servo.h>

Servo myservo1; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;

void setup()
{
Serial.begin(9600);

myservo1.attach(11); // attaches the servo on pin 9 to the servo object
myservo2.attach(10);
myservo3.attach(9);
myservo4.attach(6);
myservo5.attach(5);
}

void loop()
{
if(Serial.available() >=5)
{
byte servoVal1 = Serial.read();
byte servoVal2 = Serial.read();
byte servoVal3 = Serial.read();
byte servoVal4 = Serial.read();
byte servoVal5 = Serial.read();


// Send the servo to the position read...  (note: you get to make this happen)
myservo1.write(servoVal1);
myservo2.write(servoVal2);
myservo3.write(servoVal3);
myservo4.write(servoVal4);
myservo5.write(servoVal5);
}
}
-----------------------------------------------------

all i want to do like this
http://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand/?ALLSTEPS

but why its not working for me?
it's can be problem that i use LDR? not a flex sensors?

PaulS

Code: [Select]
byte servoValue1;
byte servoValue2;
byte servoValue3;
byte servoValue4;
byte servoValue5;

What are these for?

Code: [Select]
Serial.println(servoVal1);
Serial.println(servoVal2);
Serial.println(servoVal3);
Serial.println(servoVal4);
Serial.println(servoVal5);

Lets say that all the pots were in the middle of their range. You would then be sending:
"90<cr><lf>90<cr><lf>90<cr><lf>90<cr><lf>90<cr><lf>"

Code: [Select]
if(Serial.available() >=5)
{
byte servoVal1 = Serial.read();
byte servoVal2 = Serial.read();
byte servoVal3 = Serial.read();
byte servoVal4 = Serial.read();
byte servoVal5 = Serial.read();

And then assigning '9' to servoVal1, '0' to servoVal2, <cr> to servoVal3, <lf> to servoVal4, and '9' to servoVal5.

Quote
myservo1.write(servoVal1);
myservo2.write(servoVal2);
myservo3.write(servoVal3);
myservo4.write(servoVal4);
myservo5.write(servoVal5);
Those don't seem like reasonable positions to send the servos to.



The art of getting good answers lies in asking good questions.

altairscorpio

Code: [Select]
byte servoValue1;
byte servoValue2;
byte servoValue3;
byte servoValue4;
byte servoValue5;

What are these for?



I don't know why i write it... It's not used...

So! I found out what's the problem, so i needed write not PRINTLN but write:

Code: [Select]

Serial.println(servoVal1);
Serial.println(servoVal2);
Serial.println(servoVal3);
Serial.println(servoVal4);
Serial.println(servoVal5);

--->
Serial.write(servoVal1);
Serial.write(servoVal2);
Serial.write(servoVal3);
Serial.write(servoVal4);
Serial.write(servoVal5);


And it's working, when i connect directly RX -> TX ; TX -> RX

But something went wrong, when i connect bluetooth, servo started doing the same thing, what is shown in the video....

Strange, directly working... but throught the bluetooth not... Whats can be wrong?

PaulS

Quote
Whats can be wrong?
Could be the software that you changed and didn't post.
Could be the hardware which you've only vaguely hinted at. A schematic (for both ends) would be useful.
The art of getting good answers lies in asking good questions.

Rupert909

Seems to me you need to test each of your many systems one at a time. Pot-meters, servos, serial comunication between two arduinos and finally some bluetooth?

Doing Serial.write() sends the actual byte value, 0..255, where as Serial.print sends the bytes representing a value converted to string. I see many examples sending numbers as text, which is useful only if the other end is connected to the serial monitor, that is, to be read by humans.

Finally, for a project of this scope, you really need classes and encapsulation, not just a big "sketch" file.

The internet is a great thing. Use it.
:s/internet/mind/g
Real Programmers use ++C

Go Up