Sorry ich weiß nicht wie ich den tex in die Box kriege aber ist ja auch egal der Text ist noch nicht perfekt ,da es nur die example move1 datei ist die ich abgeändert habe
Code:
// Includes:
#include "RP6RobotBaseLib.h" // The RP6 Robot Base Library.
void bumpersStateChanged(void)
{
DDRA |= (E_INT1); // PA4 (IT1) als Ausgang definieren
DDRC |= (SCL | SDA); // PC0, PC1 als Ausgänge definieren
uint8_t i; // Variable i
uint8_t a; // Variable a
uint8_t c; // Variable c
PORTA |= E_INT1;
if(bumper_left)
{
for(a=0; a<5; a++)
{
for(i=0; i<70; i++)
{
PORTA |= E_INT1; // PA4 high
sleep(7);
PORTA &= ~E_INT1; // PA4 low
mSleep(15);
}
for(c=0; c<70; c++)
{
PORTA |= E_INT1; // PA4 high
sleep(15);
PORTA &= ~E_INT1; // PA4 low
mSleep(15);
}
for(i=0; i<70; i++)
{
PORTA |= E_INT1; // PA4 high
sleep(23);
PORTA &= ~E_INT1; // PA4 low
mSleep(15);
}
}}
else
for(a=0; a<5; a++)
{
for(i=0; i<70; i++)
{
PORTC |= SCL; // PA4 high
sleep(7);
PORTC &= ~SCL; // PA4 low
mSleep(15);
}
for(c=0; c<70; c++)
{
PORTC |= SCL; // PA4 high
sleep(15);
PORTC &= ~SCL; // PA4 low
mSleep(15);
}
for(i=0; i<70; i++)
{
PORTC |= SCL; // PA4 high
sleep(23);
PORTC &= ~SCL; // PA4 low
mSleep(15);
}
}
if(bumper_right)
{
PORTC |= SDA; // PC1 high
mSleep(2000);
PORTC &= ~SDA; // PC1 lo
}
}
/**
* This function checks Stopwatch1 all the time. If stopwatch 1 is
* not running, the function does not do anything. As soon as the
* stopwatch is started, two LEDs begin to blink!
*/
void blink(void)
{
if(getStopwatch1() > 500) // 500ms
{
statusLEDs.LED2 = !statusLEDs.LED2; // Toggle LED bit in LED shadow register...
statusLEDs.LED5 = !statusLEDs.LED5;
updateStatusLEDs();
setStopwatch1(0);
}
}
/*****************************************************************************/
// Main:
int main(void)
{
initRobotBase();
setLEDs(0b111111);
mSleep(1500);
setLEDs(0b100100);
// Set Bumpers state changed event handler:
BUMPERS_setStateChangedHandler(bumpersStateChanged);
powerON(); // Turn Encoders, Motor Current Sensors
// (and ACS IR Receiver and PWRON LED) on.
// ATTENTION: Automatic Motor control will not work without this!
// -------------------------
// With the following two commands, the RP6 will start to move in a circle.
// We simply set the direction to forwards:
// and afterwards we set the speed of the left and right motors to different
// values (80 for left, and 30 for right in this example):
PORTA |= E_INT1;
// The function
// void moveAtSpeed(uint8_t desired_speed_left, uint8_t desired_speed_right)
// sets the desired speeds. The automatic motor control will try to maintain
// this speed even if the motors get blocked or the robot has to move up a
// ramp or drive over a small obstacle.
// At least this will be the case if you always call task_RP6System() frequently
// out of the main loop!
// Maximum speed is 200. And if you execute the command:
// moveAtSpeed(0,0);
// the Robot will stop and turn motors off.
// Values below 8 will not work properly as this is just too slow to regulate
// accurately.
// ATTENTION: If you use high speeds all the time, this will result in shorter
// gears and motors lifetime. It is recommended to use only speed values
// between 10 and 160! It is no problem to use 200 for some seconds, but
// you should not let the Robot drive at such high speed all the time!
// Main loop:
while(true)
{
// If we hit an obstacle, the bumperStateChanged Handler will start
// Stopwatch 1 and then this task will let two LEDs blink:
blink();
// In the main loop we need to call task_RP6System() all the time!
// This function calls the Motor control functions that automatically
// regulate the motor speed:
task_RP6System();
}
return 0;
}
Lesezeichen