diff options
author | Martin Možina <martin.mozina@fri.uni-lj.si> | 2015-10-14 18:08:44 +0200 |
---|---|---|
committer | Martin Možina <martin.mozina@fri.uni-lj.si> | 2015-10-14 18:08:44 +0200 |
commit | 531bde7a2fe3d643e9b6ffe690405b6cc07c4964 (patch) | |
tree | 9fcdd54ec25cacc32cd5aaacfb731c174278fab8 /robot/problems/introduction/followline/naloga12_followLine.py | |
parent | 1b936a961e39b2a71b5a773776474446f0c58447 (diff) | |
parent | b1deb24a05a380450ed9dc77c3155a16bd204dfc (diff) |
Merge branch 'master' of 192.168.15.97:codeq-problems
Diffstat (limited to 'robot/problems/introduction/followline/naloga12_followLine.py')
-rw-r--r-- | robot/problems/introduction/followline/naloga12_followLine.py | 31 |
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' ) |