Pages: 1 2 3 [4]   Go Down
Author Topic: 2 servos (or any functions) operating simultaneously?  (Read 11889 times)
0 Members and 1 Guest are viewing this topic.
denver
Offline Offline
Newbie
*
Karma: 0
Posts: 35
...no matter where you go, there you are
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AWOL:
I can't say it makes or had made much sense to me either.  That just happened to be my last fairly random guess at changing the statement before I posted the code.  But, that's why I posted it, because I don't understand what was wrong with it in the first place before I tried a number of different combinations in order to at least get it to compile.

You already made it clear it doesn't make sense and this is what I already know as well, so further describing how it is senseless using simile is redundantly saying it again with a nice touch of sarcasm.  Although it may help me realize how little I understand about programming in C++, it doesn't exactly help me get any closer to my goal of operating servos for a hexapod which is the reason for this thread.

I was hoping to gain insight into how this code could be corrected, rearranged or at least experimentally altered, or pointed in some useful direction that may lead towards a solution.  A suggestion for a different approach, or as to how it might be changed, or added to, or parts to be removed would probably benefit my situation.  If your brain refuses to recognize what is going on, it would seem that there is little motivating any investigation into the underlying issue/s with this code, and then I wonder, why bother.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Get rid of this:
Code:
   MegaServo MegaServo;
and the line that references it in setup.

Change this:
Code:
void Servos digitalWrite.MegaServo( )
to this:
Code:
void SetupServos( )
and call it from setup. That'll get you closer, though I didn't compile it, so it may be closer but with a new set of compiler error messages.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25709
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Quote
If your brain refuses to recognize what is going on, it would seem that there is little motivating any investigation into the underlying issue/s with this code, and then I wonder, why bother.
Because you asked me to.
Quote
if you would care to expand on your comment a bit and share some of the wisdom I am not privy to,
I would more than appreciate being exposed to what you know about it. 

There was no sarcasm.
You'll just have to trust me on that.
You wouldn't like me when I'm sarcastic.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

denver
Offline Offline
Newbie
*
Karma: 0
Posts: 35
...no matter where you go, there you are
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

wildbill:

Thank you for your suggestions, I will try that and see what happens.

AWOL:

I can really only gather that you deem my attempts at composing a code I can use as hardly worth looking into.  On the other hand I would have to consider my query as worthy of attention seeing as how there are over 2000 views of this thread.  That would imply to me that there is a substantial number of people interested in the exact same information but who may be without the patience to be persistent in asking for help with it.
So when you get your dander up, do you shred your clothes and turn green? (just kidding) smiley-mr-green
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
seeing as how there are over 2000 views of this thread.
Some of us tuned in just to laugh.
Logged

denver
Offline Offline
Newbie
*
Karma: 0
Posts: 35
...no matter where you go, there you are
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PaulS:
What a knee slapper, glad I don't know what else you do for fun.  I always thought I was amusing, either that or funny looking. 
So when you're done wiping your chin, ya wanna post a USEFUL comment?  Interject some information that is actually demonstrative of your programming prowess?
Judging from the cocky remarks, the hassle involved is too great and it's much easier to leave snappy critiques that generate that satisfying feeling of self aggrandizement. 
Perhaps I was a bit presumptuous thinking I could come here, without any experience, for more than a spitting contest but to get help and learn a few things.
I wish I could say I appreciate all that you've offered here, Paul, my good buddy smiley-wink
Logged

Türkiye
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everbody,
I read posts but I couldnt figure out that can we run 2 servo (or multi function) at same time. (Note that; 2 servos (or more) will not work same degrees they will work different degrees simultaneously.) Does any body know anything?

Note:http://forum.arduino.cc/index.php/topic,118652.0.html
( I also checked above topic.Pauls says we cant.)

best regards
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25709
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you're asking "can I control two or more servos to the same or different positions simultaneously using the Servo library?" then the answer is "yes".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Türkiye
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for reply. new questions
1.How?
2.Any example? (Pls note that: Servos will work whenever I want, (different positions, maybe different time...))
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25709
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
1.How?
2.Any example?
Four servos, independently and simultaneously.
(Uncompiled, untested)
Code:
const byte N_SERVOS = 4;
const byte servoPin [N_SERVOS] = {2, 3, 4, 5}; //whatever
Servo servo [N_SERVOS]; //simplistic controls on A0, A1...A(n-1)
void setup ()
{
  for (int i = 0; i < N_SERVOS; i++) {
    servo [i].attach (servoPin [i]);
  }
}

void loop ()
{
  for (int i = 0; i < N_SERVOS; i++) {
    servo [i].write (map (analogRead (i), 0, 1024, 0, 180));
  }
}
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for reply. new questions
1.How?
2.Any example? (Pls note that: Servos will work whenever I want, (different positions, maybe different time...))

http://forum.arduino.cc/index.php?topic=139121.msg1046613#msg1046613
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Türkiye
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AWOL and zoomkat thanks for reply.
To AWOL; Your codes works well,
To evolion; Your codes couldnt works fine at my system ( has 2 servos (even I entered serial to 30c,180b,70a,120d,)) , or I couldnt understand enough.(maybe it need different voltage sources)
Logged

Pages: 1 2 3 [4]   Go Up
Jump to: