Hi,
gestern habe ich mich doch noch kurz dran gesetzt und schrieb mein erstes, winziges Programm für den Roboter. Das Ziel: Im Kreis herum fahren. ![]()
Um das zu erreichen, braucht man nur recht wenig Code, die 3pi API bietet schon einiges:
/*******************************************************
* CircleDrive *
* *
* Author: Manuel Rauber *
* *
* Date: 25.07.2009 *
* *
* Purpose: Let 3pi drive a little circle *
* *
* Usage: *
* Press Button B to start the program *
********************************************************/
// Include 3pi API
#include <pololu/3pi.h>
int main() {
// Wait for the user. He has to press the B Button to start
while (!button_is_pressed(BUTTON_B));
wait_for_button_release(BUTTON_B);
delay_ms(2000);
// Infinite loop
while (1) {
// Drive 2 secs straight on
set_motors(40, 40);
delay_ms(2000);
// Do a 90 Degree turn to the left
set_motors(-80, 80);
delay_ms(180);
}
}
