6 Servo Project

Hi, im looking for some help on my project. Im wanting to use 6 servos on a nintendo ds to control the buttons but im having trouble with the code part. Not really expierenced with coding. i tried using the example code that you can look at in the editor, but im getting errors when i try to download it to the micro controller. I am using the Ardiuno Micro. Here is my code currently, its just basic right now as i just want to get the servos moving before i get more advanced.

#include <Servo.h>
*/ Servo myservo A

Servo myservo B

Servo myservo Up

Servo myservo Left

Servo myservo Down

Servo myservo Right

int pos = 0

void setup() {
myservo A.attach(A5)
myservo B.attach(A4)
myservo Up.attach(A3)
myservo Left.attach(A2)
myservo Down.attach(A1)
myservo Right.attach(A0)
}

void loop() {
for (pos = 0; pos <= 180; pos += 1)

myservo A.write(pos);
delay(15);

myservo.B write(pos);
delay(15);

myservo.Up write(pos);
delay(15);

myservo.Left write(pos);
delay(15);

myservo.Down write(pos);
delay(15);

myservo.Right write(pos);
delay(15);

I thought at some point im supposed to declare a name with the pin, which i thought i did but im not sure. Thanks for any help!

There is a lot wrong with that code.

*/ Servo myservo A

/ is a start of a block comment. There is no ending/. Why is the /* there?

Servo myservo B
Servo myservo Up

Bad syntax. You can use myservo_B but not as space between myservo and B. Same with the rest.

Servo myservo B
Servo myservo Up

There must be a semicolon to end each statement. Same with the rest.

Servo myservo B;
Servo myservo Up;
    myservo A.attach(A5)
    myservo B.attach(A4)
    myservo Up.attach(A3)
    myservo Left.attach(A2)
    myservo Down.attach(A1)
    myservo Right.attach(A0)

You need to change these to match what names you give the objects above.

You must give the pos variable a data type when pos is created.

I just saw that pos is global.

There are no curly brackets to enclose the statements in the for loop block. Only the first statement after the for will repeat. The curly bracket to close loop() is missing.

myservo A.write(pos);

Bad syntax on the write method. Same trouble with the names.

There is no way that a servo is going to move form 180 to 0 in 15 milliseconds when the loop() repeats.

Please use code tags when posting code. In the future, when you have errors, post the entire error message. It makes it easier to help you.

How to use this forum-please read.

How are you powering all of those servos? The Arduino sure as he** can't do it. You need, probably, 4 to 6 Amps to start all at once.

You can’t put random dots and spaces in the middle of names. So “myservo B” is wrong. And it’s even more wrong when later you try to use it as myservo.B

You could use myservoB, myservoUp etc in all those places and you’d be getting nearer.

You need to look a little more closely at the example codes provided. You have to use correct syntax, you can’t just invent your own. The { } braces are very important and most of yours are missing.

Also try verifying your code in the IDE and read all the errors you get carefully, see if you can’t work out what they’re telling you. If you can’t, then post the full error listing here so we can help.

BTW the errors and your code should be posted in code tags. If you read the post “How to use this forum - please read” at the top of the forum it will explain how (and a lot more).

Steve

Thanks for the help. Im kind of a bad guesser when doing something i have never done before, so thats why some of this is way off. I will look through everything, make the changes and see what error codes remain, and update this if there is something else i cant figure out.