Also ... ich habe jetzt erstmal angefangen die "Servo-Rada" Funktionen zusammen zu führen, jedoch scheitere ich da kläglich, weil ich die beiden Programme noch nicht richtig verstehe und was das C programmieren angeht sowieso noch ein Anfänger bin... kann mir da jamand helfen die beiden zusamen zu stellen?
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=8;
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++; servo_delay= 220; break;
}
servo(10,14,10);
servo(10,13,10);
servo(10,12,10);
servo(10,11,10);
servo(10,10,10);
servo(10,9,10);
servo(10,8,10);
servo(10,7,10);
servo(10,6,10);
servo(10,5,10);
servo(10,6,10);
servo(10,7,10);
servo(10,8,10);
servo(10,9,10);
servo(10,10,10);
servo(10,11,10);
servo(10,12,10);
servo(10,13,10);
servo(10,14,10);
servo(10,15,10);
servo(10,16,10);
servo(10,17,10);
servo(10,18,10);
servo(10,19,10);
servo(10,20,10);
servo(10,21,10);
servo(10,22,10);
servo(10,23,10);
servo(10,24,10);
servo(10,23,10);
servo(10,22,10);
servo(10,21,10);
servo(10,20,10);
servo(10,19,10);
servo(10,18,10);
servo(10,17,10);
servo(10,16,10);
servo(10,15,10);
}
return 0;
}
und das von radbruch
Code:
#include "RP6RobotBaseLib.h"
uint8_t radar_pos;
uint8_t radar[38][3]=\
{{10,14,10},{10,13,10},{10,12,10},{10,11,10},{10,10,10}\
,{10,9,10},{10,8,10},{10,7,10},{10,6,10},{10,5,10}\
,{10,6,10},{10,7,10},{10,8,10},{5,9,10},{10,10,10}\
,{10,11,10},{10,12,10},{10,13,10},{10,14,10},{10,15,10}\
,{10,16,10},{10,17,10},{10,18,10},{10,19,10},{10,20,10}\
,{10,21,10},{10,22,10},{10,23,10},{10,24,10},{10,23,105}\
,{10,22,10},{10,21,10},{10,20,10},{10,19,10},{10,18,10}\
,{10,17,10},{10,16,10},{10,15,10}};
void servo(uint8_t s1, uint8_t s2, uint8_t s3)
{
}
int main(void)
{
initRobotBase();
radar_pos=0;
startStopwatch1();
moveAtSpeed(100,100);
while(1)
{
if (getStopwatch1()>1000) // eine Radar-Position pro Sekunde
{
servo(radar[radar_pos][0],radar[radar_pos][1],radar[radar_pos][2]);
radar_pos++;
if (radar_pos == 38) radar_pos=0;
setStopwatch1(0);
}
task_RP6System();
}
return(0);
}
Danke für hilfe!
Lesezeichen