LED.h & Umwandeln.h
Embed:
(wiki syntax)
Show/hide line numbers
basic.h
00001 #include "mbed.h" 00002 #include "m3pi_ng.h" 00003 00004 m3pi pi; 00005 00006 int main() { 00007 00008 // Parameters that affect the performance 00009 float speed = 0.7; //geschw. 00010 float correction = 0.5; //korrektur links, rechts 00011 float threshold = 0.5; //schwelle, korrektur 00012 00013 pi.locate(0,1); //vorgefertigte position, ausrichten 00014 pi.printf("Runde: "); 00015 00016 wait(2.0); 00017 00018 pi.sensor_auto_calibrate(); 00019 00020 while (1) { 00021 00022 // -1.0 is far left, 1.0 is far right, 0.0 in the middle 00023 float position_of_line = pi.line_position(); 00024 00025 // Line is more than the threshold to the right, slow the left motor 00026 if (position_of_line > threshold) { 00027 pi.leftt_motor(speed); 00028 pi.right_motor(speed-correction); 00029 } 00030 00031 // Line is more than 50% to the left, slow the right motor 00032 else if (position_of_line < -threshold) { 00033 pi.right_motor(speed); 00034 pi.left_motor(speed-correction); 00035 } 00036 00037 // Line is in the middle 00038 else { 00039 pi.forward(speed); 00040 } 00041 } 00042 }
Generated on Thu Jul 21 2022 03:19:50 by
1.7.2