i am using this short program..

Servo myservo;
 
int pos = 0;

void setup()
{
      myservo.attach(9);
}

void loop() {
    incomingByte = Serial.read();
    while ( incomingByte == 97 && Serial.available () == 0) //left aileron
    {
        myservo.write(45);
    }
    while ( incomingByte == 100 && Serial.available () == 0) //right aileron
    {
        myservo.write(135);
    }
    while ( incomingByte == 119 && Serial.available () == 0) //pitch down
    {
        myservo.write(45);
    }
}


alright, i understand this program sends a 45 degree to the servo, and i believe the servo is output pin 1. how should i modify this program, or maybe the variables, to allow me to control more ch at the same time instead of 1. in this case, as from the program above, my third one is to control pitch, which is ch 2, but i cant get ch 2 moving, no matter what chat i type, ch 1 will move. is it due to the declaring of myservo.attach(9)?
if yes, how to i modify it?

1 more question:
what is the code that sends the signal to the brushless motor to allow the motor to rotate? like for the servo case, its myservo.write..

thanks..

darren

Views: 125

Reply to This

Replies to This Discussion

I'm by no means a master at C+, but I believe you can add the line myservo.attach(pin number) to your loop with the other myservo, and your code should move both servos
i tried adding myservo.attach(4) in the setup() but it cause the previous servo to also stop moving..
about 2nd question; the answer is ESC
the answer is ESC? means?
i know what esc means.. but my second question is asking for the code..
this might help.. thanks..
np :)
Prior to the first line:
#include servo.h
// brackets required around servo.h.

Servo myservo1 // create first servo object
Servo myservo2 // create second servo object

myservo1.attach(9); // attaches the servo on pin 9 to the first servo object
myservo2.attach(10); // attaches the servo on pin 10 to the second servo object
// I believe pins 3, 5, 6, 9, 10, and 11 are the PWM pins required for servo output on a standard Arduino.

myservo1.write(45); // will turn the servo to 45 degrees. 0-180 degree range.
myservo2.writeMicroseconds(1500); // alternate usage in microseconds.
// 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle for servos.
// use this for the brushless motor ESC. It is a type of servo, controlling rpms instead of angle.
hey thanks! i got the ch 1 and 2 done.. figuring how to do the throttle and ch 4. if i want get the ch 4 working, do i need do some soldering?
hey.. my program above, is like when i press "a", it turns the servo to 45degrees, and i never come back to 0degree. how do i modify the program to make it only move when i press and back to zero when i release?

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service