blob: 6459043800908db49bae15f6dda9793e7b6ee3b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/python
print ("""
Naloga 6:
Robota postavi pred zid, tako da bo od njega oddaljen vsaj 1 m; vmes naj ne bo ovir.
Napisi program, s katerim bo robot vozil naravnost proti zidu z 80% mocjo.
Na razdalji 50 cm od zida naj robot zmanjsa hitrost na 20%, na razdalji 20 cm od zida pa naj se ustavi.
""")
import sys
sys.path.append('/home/user/codeq')
import time
from ev3dev import *
from mindstorms_widgets import mindstorms_widgets
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
robot.connect_sensor( 'ultrasonic' )
robot.move_steering( 'on', power=80 )
while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 500:
pass
robot.move_steering( 'on', power=20 )
while robot.ultrasonic_sensor_measure( 'distance-cm' ) > 200:
pass
robot.move_steering( 'off' )
|