Pages: 1 [2]   Go Down
Author Topic: Getting my second servo to work  (Read 1321 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

MarkT, I'm sorry I'm not really sure how to clear the serial buffer do I use while
Code:
(Serial.available())
  Serial.read();
And by promting you mean I should get rid of
Code:
Serial.println("Press 4 to turn Arduino pin 4 servo to 180 or 6 to turn it to 0:");  // goes from 0 degrees to 180 degrees
and just combine it with the first serial.println?
Thanks.
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 51
Posts: 1729
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What if you try to control the first servo by anything else than "0" and "1" ?
So what if you test for "2" and "3", and what if you press wrong keys ?
And do you need to read serial, then control servo 1, and then read serial again and control servo 2 ?
Or is reading serial and then controlling the corresponding servo also an option ?
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I control the first servo with anything else then 1 or 0 nothing happens. I have now plugged in my first servo in to pin 4 which I was using for my second servo and I discoverd if I press 4 and 6 then the servo does work. So I think that the arduino board just can't or doesn't want to control the other servo (its a different brand). Reading the serial and then controlling the corresponding servo is a option. Thanks for the reply
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I just grabbed a servo from an RC car and this one does work so now both servos are working smiley one thing though when I write 1, 0, 4, or 6 I have to type it then send it and then type it and send it again for it to respond. Any ideas?
Logged

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

Use a proper terminal emulator, like hyperterm or putty
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.

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using putty now and I still have that same problem. Could it be that I have this running for my second servo? :
Code:
while (!Serial.available());   // stay here so long as COM port is empty
[/s]
Nevermind this part wasn't the problem.
« Last Edit: May 09, 2013, 07:46:15 am by nitromt2 » Logged

Pages: 1 [2]   Go Up
Jump to: