Code:
#include "asuro.h"
void start(void){
unsigned char los[12];
StatusLED(YELLOW);
SerRead(los, 12, 0);
SerWrite("Fahre Los!\n\r", 13);
StatusLED(GREEN);
MotorDir(FWD,FWD);
MotorSpeed(245,255);
BackLED(OFF,OFF);
}
void stop(void){
unsigned char pause[15];
SerRead(pause, 15, 0);
SerWrite("Halte an!\n\r", 12);
MotorDir(BREAK,BREAK);
StatusLED(YELLOW);
BackLED(OFF,OFF);
}
void restart(void){
unsigned char bwd[12];
SerRead(bwd, 12, 0);
SerWrite("Fahre zurück!\n\r",16);
MotorDir(RWD,RWD);
MotorSpeed(245,255);
StatusLED(RED);
BackLED(OFF,OFF);
}
void left(void){
unsigned char leftcommand[12];
SerRead(leftcommand, 12, 0);
SerWrite("Fahre nach links!\n\r",20);
MotorDir(FWD,FWD);
MotorSpeed(190,255);
StatusLED(GREEN);
BackLED(ON,OFF);
}
void right(void){
unsigned char rightcommand[12];
SerRead(rightcommand, 12, 0);
SerWrite("Fahre nach rechts!\n\r", 21);
MotorDir(FWD,FWD);
MotorSpeed(255,200);
StatusLED(GREEN);
BackLED(OFF,ON);
}
void leftb(void){
unsigned char leftbcommand[12];
SerRead(leftb, 12, 0);
SerWrite("Fahre rückwerts nach links!\n\r",30);
MotorDir(RWD,RWD);
MotorSpeed(190,255);
StatusLED(RED);
BackLED(ON,OFF);
}
void rightb(void){
unsigned char rightbcommand[12];
SerRead(rightbcommand, 12, 0);
SerWrite("Fahre rückwerts nach rechts!\n\r",31);
MotorDir(RWD,RWD);
MotorSpeed(255,200);
StatusLED(RED);
BackLED(OFF,ON);
}
void end(void){
unsigned char endcommand[15];
SerRead(endcommand, 15, 0);
SerWrite("Schlafe!\n\r",11);
MotorDir(BREAK,BREAK);
StatusLED(OFF);
BackLED(OFF,OFF);
Sleep(255);
Sleep(255);
}
int main(void)
{
Init();
while(1){
start();
stop();
stop();
left();
stop();
stop();
right();
stop();
stop();
restart();
stop();
stop();
leftb();
stop();
stop();
rightb();
stop();
stop();
end();
end();
}
return 0;
}
Ich hoffe der Code erschlägt dich nicht.
Lesezeichen