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: 124

Reply to This

Replies to This Discussion

How do i modify the "while ( incomingByte == 97 && Serial.available () == 0)" so that if a is press, it turn 45degree, when i release, it goes back to 0degree instead of staying at 45..
i still cant figure out this problem.. someone help me to modify..

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