motor.run_for_degrees(-90) def pen_down(): motor.run_for_degrees(90) motor_pair = MotorPair('B', 'A') motor_pair.set_default_speed(50) motor_pair.set_motor_rotation(wheel_radius * 2 * math.pi, 'cm') for i in range(30): pen_down() motor_pair.move(-random.randrange(1,3), 'cm', speed = 20) pen_up() r = random.randrange(2) if r==0: motor_pair.move(pen_radius, 'cm') motor_pair.move_tank(axis_radius*math.pi/2, 'cm', left_speed=-50, right_speed=50) motor_pair.move(-pen_radius, 'cm') if r==1: motor_pair.move(pen_radius, 'cm') motor_pair.move_tank(-axis_radius*math.pi/2, 'cm', left_speed=-50, right_speed=50) motor_pair.move(-pen_radius, 'cm') if r==2: pass hub.light_matrix.write('done')
def pen_up(): motor.run_for_degrees(-90) def pen_down(): motor.run_for_degrees(90) motor_pair = MotorPair('B', 'A') motor_pair.set_default_speed(20) motor_pair.set_motor_rotation(wheel_radius * 2 * math.pi, 'cm') pen_down() motor_pair.move_tank(axis_radius * math.pi * 2.05, 'cm', left_speed=-25, right_speed=25) #pen_up() #pen_down() motor_pair.move(-pen_radius * 2, 'cm') pen_up() motor_pair.move(pen_radius * 2, 'cm') motor_pair.move_tank(axis_radius * math.pi * -0.5, 'cm', left_speed=-25, right_speed=25)
def pen_down(): motor.run_for_degrees(90) motor_pair = MotorPair('B', 'A') motor_pair.set_default_speed(20) motor_pair.set_motor_rotation(wheel_radius * 2 * math.pi, 'cm') for i in range(4): if i > 0: motor_pair.move(pen_radius, 'cm') motor_pair.move_tank(axis_radius * math.pi / 2, 'cm', left_speed=-20, right_speed=20) motor_pair.move(-pen_radius, 'cm') pen_down() motor_pair.move(-line_length, 'cm') pen_up() motor_pair.move(pen_radius, 'cm') motor_pair.move_tank(axis_radius * math.pi * 0.2, 'cm', left_speed=-20, right_speed=20) motor_pair.move(-pen_radius + line_length / 2, 'cm')