I am just a Beginner with RP6.
First thing first.
I have connected SRF08 to I2C.
and Servo to XBUS 2 ( Servo out SDA). I think it supposed to be changed because SRF already there.
Where should I Connect it and what change should do in the following Dirk's code.
#include "RP6RobotBaseLib.h"
#define SERVO_OUT SDA
#define LEFT_TOUCH 554
#define RIGHT_TOUCH 254
#define PULSE_ADJUST 8
#define PULSE_REPETITION 19
void initSERVO(void)
{
DDRC |= SERVO_OUT;
PORTC &= ~SERVO_OUT;
startStopwatch1();
}
void pulseSERVO(uint8_t position)
{
cli();
PORTC |= SERVO_OUT;
delayCycles(LEFT_TOUCH);
while (position--) {
delayCycles(PULSE_ADJUST);
}
PORTC &= ~SERVO_OUT;
sei();
}
void task_SERVO(void)
{static uint8_t pos;
if (getStopwatch1() > PULSE_REPETITION) {
pulseSERVO(pos);
if (getStopwatch2() > 4 {
pos++;
if (pos > RIGHT_TOUCH) {pos = 0;}
setStopwatch2(0);
}
setStopwatch1(0);
}
}
int main(void)
{
initRobotBase();
mSleep(2500);
setLEDs(0b111111);
mSleep(500);
setLEDs(0b000000);
initSERVO();
startStopwatch2();
while(true)
{
task_SERVO();
task_RP6System();
}
return 0;
}
Lesezeichen