Skip to content

Commit

Permalink
added manual servo control function
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjairo committed Jan 2, 2012
1 parent 5f4cc05 commit 837d38a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ int main(void) {
esc_manual_control();
break;

case 'y':
yaw_manual_control();
break;

case 'b':
cmd_board_info();
break;
Expand Down
43 changes: 43 additions & 0 deletions yaw-servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,46 @@ void set_servo_angle(float angle)
if(duty > SERVO_MAX) duty = SERVO_MAX;
pwmWrite(YAW_SERVO_PIN, duty);
}

void yaw_manual_control()
{
SerialUSB.println("Press \'j\' to lower speed.");
SerialUSB.println("Press \'k\' to increase speed.");
SerialUSB.println("Press \'z\' to zero command.");
SerialUSB.println("Any other key zeroes command and exits");
SerialUSB.println();

uint8 input;
float angle = 0;
while (1) {

input = SerialUSB.read();
if (input == 'j')
{
angle -= 1;
}
else if(input == 'k')
{
angle += 1;
}
else if(input == 'z')
{
angle = 0;

}else{
break;
}


if (angle > 90) angle = 90;

SerialUSB.println(angle);

set_servo_angle(angle);
delay(20);
}

set_servo_angle(0.0);


}
2 changes: 1 addition & 1 deletion yaw-servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

void yaw_servo_init();
void set_servo_angle(float angle);

void yaw_manual_control();


// Servo constants
Expand Down

0 comments on commit 837d38a

Please sign in to comment.