var step_counter_left var step_counter_right var time_counter var general_counter var R2 = R1/3 var R3 = R2/3 var Vr1 var Vr2 var Vr3 var tr1 #unité: time counter avec period de 20ms var tr2 var tr3 var tl1 var tl2 var tl3 var t1 var t2 var t3 var mode = 0 #mode 0 = attente de lancement #mode 1 = cercle 1 de rayon R1 #mode 2 = cercle 2 de rayon R2 #mode 3 = cercle 3 de rayon R3 timer.period[0] = 20 #* onevent motor step_counter_right = step_counter_right + motor.right.speed step_counter_left = step_counter_left + motor.left.speed *# onevent timer0 time_counter ++ if mode == 0 or general_counter == 4 then motor.left.target = 0 motor.right.target = 0 mode = 0 general_counter = 0 call leds.bottom.left(30,30,30) call leds.bottom.right(30,30,30) call leds.top(30,30,30) elseif mode == 1 then motor.left.target = Vl1 motor.right.target = Vr1 call leds.bottom.left(30,0,0) call leds.bottom.right(30,0,0) call leds.top(30,0,0) if time_counter >= t1 then mode++ time_counter = 0 end elseif mode == 2 or mode == 4 or mode == 6 then motor.left.target = Vl2 motor.right.target = Vr2 call leds.bottom.left(0,30,0) call leds.bottom.right(0,30,0) call leds.top(0,30,0) if time_counter >= t2 then mode++ time_counter = 0 end elseif mode == 3 or mode == 5 or mode == 7 then motor.left.target = Vl3 motor.right.target = Vr3 call leds.bottom.left(0,0,30) call leds.bottom.right(0,0,30) call leds.top(0,0,30) if time_counter >= 3*t3 then if mode == 7 then mode = 1 general_counter++ else mode++ end time_counter = 0 end end onevent button.forward call math.muldiv(Vr1, Vl1, 2*R1-Ri, 2*R1+Ri) call math.muldiv(Vr2, Vl2, 2*R2-Ri, 2*R2+Ri) call math.muldiv(Vr3, Vl3, 2*R3-Ri, 2*R3+Ri) call math.muldiv(tr1, 785, R1-Ri, 3*Vr1) call math.muldiv(tr2, 785, R2-Ri, 3*Vr2) call math.muldiv(tr3, 785, R3-Ri, 3*Vr3) call math.muldiv(tl1, 686, R1+Ri, 3*Vl1) call math.muldiv(tl2, 819, R2+Ri, 3*Vl2) call math.muldiv(tl3, 630, R3+Ri, 3*Vl3) t1 = tl1 t2 = tl2 t3 = tl3 mode = 1 time_counter = 0 general_counter = 1 onevent button.backward mode = 0