blob: e6e19a05fdb62c1d6df5dbc1f1ce2eb72bd6f14c (
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
27
28
29
30
|
#!/usr/bin/python
# coding=utf-8
print( """
Naloga 12:
Robot naj 10 sekund sledi crni crti na beli podlagi; pri tem naj si pomaga z barvnim senzorjem.
""")
import sys
sys.path.append('/home/user/codeq')
import time
from mindstorms_widgets import *
robot = mindstorms_widgets()
robot.connect_motor( 'left' )
robot.connect_motor( 'right' )
robot.connect_sensor( 'color' )
start = time.time()
# CALIBRATION
# print 'black', robot.color_sensor_measure('reflected_light_intensity')
# print "move to white"
# time.sleep(5)
# print 'white', robot.color_sensor_measure('reflected_light_intensity')
while time.time()-start < 10:
if robot.color_sensor_measure('reflected_light_intensity') < 30:
L, R = 0, 20
else:
L, R = 20, 0
robot.move_tank( 'on', lr_power=[L,R])
robot.move_tank( 'off' )
|