Code:
#include "RP6RobotBaseLib.h"
uint8_t i, pause, servo_stellzeit, servo_delay;
void servo(uint8_t w0, uint8_t w1, uint8_t w2)
{
unsigned int count=0;
do{
PORTA |= E_INT1; // E_INT1 (Pin8)
sleep(w0);
PORTA &= ~E_INT1;
PORTC |= 1; // SCL (Pin10)
sleep(w1);
PORTC &= ~1;
PORTC |= 2; // SDA (Pin12)
sleep(w2);
PORTC &= ~2;
sleep(servo_delay-(w0+w1+w2));
//sleep(127);
} while (count++ < servo_stellzeit);
mSleep(10*pause);
}
int main(void) {
initRobotBase();
i=0;
servo_stellzeit=15;
DDRA |= E_INT1; // E_INT1 als Ausgang
DDRC |= 3; // SCL und SDA als Ausgang
// 5 - 15 - 25 // Min - Mitte - Max
servo(15,15,15); // Grundstellung
while (1)
{
switch (i)
{
case 0: i++; pause=30; servo_delay=255; mSleep(1000); break;
case 1: i++; pause=10; servo_delay=255; break;
case 2: i++; pause=10; servo_delay=127; break;
case 3: i++; pause=1; servo_delay=127; break;
case 4: i=0; pause=1; servo_delay=127; break;
}
servo(10,15,15); // Finger zurück
servo(15,15,15);
servo(20,15,15); // Finger vor
servo(15,15,15);
servo(15,10,15); // Arm runter
servo(15,15,15);
servo(15,20,15); // Arm hoch
servo(15,15,15);
servo(15,15,10); // Schulter links
servo(15,15,15);
servo(15,15,20); // Schulter rechts
servo(15,15,15);
servo(20,10,15); // Finger vor, Arm runter
servo(25,5,15);
servo(20,10,15);
servo(15,15,15);
servo(20,20,15); // Finger vor, Arm hoch, Schulter links
servo(15,15,10);
servo(10,20,10); // Finger zurück, arm hoch
servo(5,25,10);
servo(10,20,10);
servo(15,15,15);
}
return 0;
}
Alles Lösungen mit der orginalen Library und Anschluß am XBUS-Stecker. Einfach zu finden wenn man hier im RN-Forum nach "servo AND rp6 AND radbruch" sucht.
Lesezeichen