summaryrefslogtreecommitdiff
path: root/robot/problems/introduction/followline/naloga12_followLine.py
diff options
context:
space:
mode:
Diffstat (limited to 'robot/problems/introduction/followline/naloga12_followLine.py')
-rw-r--r--robot/problems/introduction/followline/naloga12_followLine.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/robot/problems/introduction/followline/naloga12_followLine.py b/robot/problems/introduction/followline/naloga12_followLine.py
new file mode 100644
index 0000000..347e89e
--- /dev/null
+++ b/robot/problems/introduction/followline/naloga12_followLine.py
@@ -0,0 +1,31 @@
+#!/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 ev3dev import *
+from mindstorms_widgets import mindstorms_widgets
+
+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' )