# Porgramme permettant de faire avancer le robot à l'aide de la flèche avant. # Le robot même s'il interagit avec l'utilisateur ne tient pas compte de son environement. # Ce programme est sous licence Creative Commons, CC-BY-NC-SA # Auteur : Georges Saliba, 2021-06-01 # vous pouvez copier et coller le code suivant dans Aseba Studio var state[4] = [0,0,0,0] var new_state[4] = [0,0,0,0] # stop timer 0 timer.period[0] = 0 # reset outputs call sound.system(-1) call leds.top(0,32,0) call leds.bottom.left(0,0,0) call leds.bottom.right(0,0,0) call leds.circle(0,0,0,0,0,0,0,0) # subroutine to display the current state sub display_state call leds.circle(0,state[1]*32,0,state[3]*32,0,state[2]*32,0,state[0]*32) onevent buttons call leds.top(0,0,32) # un appuis sur la flèche avant déclanche le programme. when button.forward == 1 do if state[0] == 0 and state[1] == 0 and state[2] == 0 and state[3] == 0 then motor.left.target = 200 motor.right.target = 200 timer.period[0] = 2000 call leds.top(32,0,0) new_state[0] = 0 new_state[1] = 1 new_state[2] = 0 new_state[3] = 0 end end call math.copy(state, new_state) callsub display_state onevent timer0 timer.period[0] = 0 if state[0] == 0 and state[1] == 1 and state[2] == 0 and state[3] == 0 then motor.left.target = 0 motor.right.target = 0 call leds.top(0,32,0) new_state[0] = 0 new_state[1] = 0 new_state[2] = 0 new_state[3] = 0 end call math.copy(state, new_state) callsub display_state