/* Batterie-Kapazitäts-Mess-Roboter BKMR-01 (C) CLIP & KLAR, 200020305 slot 1 */ // sensors #define KAP SENSOR_2 #define MITTE SENSOR_1 #define DOIT SENSOR_3 // motors #define LUFT OUT_B #define SENKEN OUT_C //variablen int speed=7; int abg, cnt; task main() { // configure the sensors SetSensor(KAP, SENSOR_TOUCH); SetSensor(MITTE,SENSOR_LIGHT); SetSensorMode(MITTE, SENSOR_MODE_PERCENT); SetSensor(DOIT, SENSOR_TOUCH); //GO! Off(LUFT+SENKEN); SetPower(LUFT+SENKEN,speed); Rev(LUFT); OnFor(LUFT,300); //start beginn; while(true) { if (DOIT==1) { Fwd(LUFT); OnFor(LUFT,300); cnt=0; abg=0; start count; while (abg==0) { // Zeit abgelaufen? if(KAP == 1) { while(KAP==1); // warten auf loslassen cnt++; } } Rev(LUFT); OnFor(LUFT,300); if (cnt < 3) { // schlechte Batterie Fwd(SENKEN); OnFor(SENKEN,450); Rev(SENKEN); while (MITTE < 40) { On(SENKEN); } Wait(30); Off(SENKEN); } else { // gute Batterie Rev(SENKEN); OnFor(SENKEN,450); Fwd(SENKEN); while (MITTE < 40) { On(SENKEN); } Wait(35); Off(SENKEN); } } } } task count() { ClearTimer(0); while (true) { if (Timer(0) > 110) { abg=1; stop count; } } }